• Call Toll Free: 1-855-909-3300

Office 365 : Building File Handler Add-ins

It is easy to make a file handler add-in for Office 365 using the File Handler application project template. These templates are available at File Handler Application which can be easily downloaded. These templates can be put in use for Visual Studio 2013 and Visual Studio 2015.

Below are the steps to download a template from File Handler Application for Creating file handlers in the Office 365

This will elaborate the process of creating a basic file handler for a file type custom file via using the File Handler application project template.

Just download the template for Visual Studio 2013 and Visual Studio 2015 from the source File Handler Application, or find it from the Online Templates section present in the New Project dialog.

Constitute to Create and then customizing the Office 365 app

Kindly note, this example is based on the File Handler application project template, such that, to get started you’ll create a new project using that template.

You can nicely download it either from File Handler Application, or locate to find it from the Online Templates section present in the New Project dialog.

Steps for downloading the template and creating the project

1. Go to the File menu, then click on New and now click & select the Project.
2. Going in the left pane, select the option Online, and in the present Visual C# category, select Office.
3. File Handler Application should be presented as an on option in the middle pane. select it, now, enter the basicfilehandler for the name, and then click OK for creating the project.

In case you are unable to install the template yet, you are going to be prompted to install the template.

In Next consecutive step, you are going to register the app with Azure AD and then amend or modify it to add the file handler extension functionality.

For registering and configuring the app using Azure AD

1. Going to the Solution Explorer, right-click on the project name and then go to option Add > Connected Service.
2. Choose Office 365 APIs, and click to Configure.
3. Click to select Register your app option.

Please Note : The text present in the Add Connected Service dialog may be varying depending on Visual Studio version you might choose to work in. Also, in case Register your app is unavailable, you might want to remove and eliminate the placeholder values for the ClientId and ClientSecret present in the web.config. To get this done, search on the following given keys and then remove them from the web.config:

<add key=”ida:ClientId” value=”[ClientId placeholder]” />
<add key=”ida:ClientSecret” value=”[ClientSecret placeholder]” />

4. Now, Sign in with a tenant administrator account to go to your Office 365 developer organization.
5. Select App Properties.
6. Add on the following to the redirect URIs list:

o http://basicfilehandler.azurewebsites.net
o https://basicfilehandler.azurewebsites.net

Pl.Note The basicfilehandler.azurewebsites.net site will be located where the file handler application will be hosted. You are going to create this when you publish this project to Azure in the consecutive steps.

7. Click to select Apply to close the App Properties dialog, and now, OK for closing the Services Manager dialog.

At this state, Visual Studio will adds the necessary NuGet packages at the project. Now you’re qualified to configure permissions for your app, that must be done in the Azure AD management portal.

1. Do Sign at the Azure Management Portal.
2. Select Active Directory , in the left navigation panel,. Ensure the Directory tab is selected, and now click on the directory name.
3. On the present directory page, choose Applications. You must watch your file handler application listed. In case you don’t observe it in the list, choose Applications my company owns present in the Show dropdown.
4. Now choose your application, and now click to select Configure present in the top menu.
5. Scroll down at the bottom of the page and then, under permissions to other applications, choose Add application.
6. Choose Microsoft Graph, and now, click on the checkmark icon.
7. Under the permissions to other applications, click to select the Delegated Permissions column and then select on Read and write files that the user selects.
8. Click on to Save button present at the bottom of the navigation bar.

Coding the file handler application

Now you’re eligible to add on the file handler specific code at the application. In case you’re using the File Handler application project template for creating the project, then just observe that a lot of this work has already been done for you.

The main tasks remaining are left for you, like to add code at the NewFile, then Open and Preview methods for specifying what should happen for the custom file type.

You can locate these methods at the FileHandlerController.cs file presnt in the Controllers folder of the project solution.

To know the Preview method, watch for the following method declaration:

public async Task<ActionResult> Preview()

To perform the Open method, watch for the following method declaration:

public async Task<ActionResult> Open()

To perform the New file method, watch for the following method declaration:

public async Task<ActionResult> NewFile()

Kindly note, the present first part of the current code existing in these methods loads the activation parameters. Activation parameters include information that Office 365 already has as a part of the POST request made to the file handler.

The code included along with the project template accesses and caches these values as soon as the file handler is activate or invoked.

Publish application

Now you’re qualified for launching to publish the application at Azure.

1. Going in Solution Explorer, just do right-click on the project and then, choose Publish.
2. Select to opt for Microsoft Azure Websites.
3. In case you are asked for credentials, duly enter the credentials which you use to manage your Azure subscription.
4. In the option Select Existing Websites, click to choose option New.
5. Type to enter basicfilehandler as the Site name.
6. In case you do not have a database server set up, then mention the Create new server; else choose the database server to use.
7. Click to choose Create.
8. Once the site is created, click on option Publish.

To Configure the file handler

After launching the file handler application, you are eligible to configure it in Office 365, now.
1. Navigate on the AddIns Manager sample tool, which can be used to make the necessary queries at the Azure AD Graph API for configuring the file handler. Using the AddIns Manager tool is going to update the app configuration present at the Azure AD.
2. When the page gets loaded at the browser, click on option Sign in present at the top right side of the page.
3. Then enter the asked credentials for the tenant admin, and select option sign in.
4. Choose the name of your file handler app present at My Applications in the left navbar.
5. The click on the option Register Add-In.
6. Going in the Register Add-In dialog, choose File Handler.
7. Click & select the drop-down menu for File Handler Add-In.
8. Now, enter the details related to your file handler. Pl.Note The protocol should be https.
9. Click and choose the Update Add-In.

Your File Handler Add-ins for Office 365 is ready!

Leave a Reply

Techarex NetWorks Products