Search code examples
azurevisual-studio-2015office365add-infilehandler

How to Develop Office 365 Custom File Handler


I heard Microsoft provides file handler add-in for custom (non-Microsoft) file types in Office 365.

I tried to do this following the tutorial found here, however it seems a bit outdated (although it was last updated in Jan 2017) because several things mentioned there are different from my environment - I use Visual Studio 2015 on Windows 10.

So basically here's what I'm trying to achieve. I have a custom file type with .encx extension, which is simply a encrypted docx file using our own cryptography algorithm. I can access to Office 365 tenant admin account. I want to allow our users to be able to open this encrypted file in OneDrive web interface.

Here's my environment:
Microsoft Visual Studio Enterprise 2015 Version 14.0.25123.00 Update 2
Microsoft .NET Framework Version 4.6.01586
Azure SDK v2.9.6

I created a new Visual C# project based on File Handler Application template in Office category from VS 2015.
And I added connected service for Office 365 API.
Since I have a free trial subscription on Azure account, I added all the required stuff like SQL database server, SQL db, Azure Active Directory - basically all the things explained in the above tutorial. And then I published and publishing was successful. I can see it live on the *.azurewebsites.net in my browser and sign in even works.

I used Addin manager sample Azure app as described in the tutorial to update add-in settings like file icon, preview/open/new endpoint link etc, and hit Update button. Now I uploaded some .encx files to OneDrive account but it still doesn't show custom icon nor open it in custom file handler (it just triggers browser file download).

I've been pulling my hair with this issue because I couldn't find any helpful/detailed answers anywhere online.

I seriously need help from Microsoft people.

UPDATE:

Now I have some progress - I can see custom file icon, .encx file now tries to show something as a preview when I select it, and opens in new tab if I click it.
The problem is Preview, Open works with my localhost URL, but not with published Azure web service URL. It says Sorry, something went wrong along with Invalid URL: |0..

Sorry, something went wrong - Invalid URL: |0.

UPDATE 2:

Here's a manifest file for Azure web service app:

{
  "appId": "0afc5455-a05b-4cc1-b241-89c717d9bce4",
  "appRoles": [],
  "availableToOtherTenants": false,
  "displayName": "MyFileHandler",
  "errorUrl": null,
  "groupMembershipClaims": null,
  "homepage": "http://my***.azurewebsites.net/",
  "identifierUris": [
    "https://filevisor.net/MyFileHandler"
  ],
  "keyCredentials": [],
  "knownClientApplications": [],
  "logoutUrl": null,
  "oauth2AllowImplicitFlow": false,
  "oauth2AllowUrlPathMatching": false,
  "oauth2Permissions": [
    {
      "adminConsentDescription": "Allow the application to access MyFileHandler on behalf of the signed-in user.",
      "adminConsentDisplayName": "Access MyFileHandler",
      "id": "5b21f973-edd5-4ace-a369-cfff0ed3b8fa",
      "isEnabled": true,
      "type": "User",
      "userConsentDescription": "Allow the application to access MyFileHandler on your behalf.",
      "userConsentDisplayName": "Access MyFileHandler",
      "value": "user_impersonation"
    }
  ],
  "oauth2RequirePostResponse": false,
  "passwordCredentials": [
    {
      "customKeyIdentifier": null,
      "endDate": "2018-02-02T05:22:35.7514025Z",
      "keyId": "b19de090-a661-402f-8ae2-624f148ff6fd",
      "startDate": "2017-02-02T05:22:35.7509019Z",
      "value": null
    }
  ],
  "publicClient": false,
  "replyUrls": [
    "http://my***.azurewebsites.net/"
  ],
  "requiredResourceAccess": [
    {
      "resourceAppId": "00000002-0000-0000-c000-000000000000",
      "resourceAccess": [
        {
          "id": "311a71cc-e848-46a1-bdf8-97ff7156d8e6",
          "type": "Scope"
        }
      ]
    },
    {
      "resourceAppId": "00000003-0000-0000-c000-000000000000",
      "resourceAccess": [
        {
          "id": "17dde5bd-8c17-420f-a486-969730c1b827",
          "type": "Scope"
        }
      ]
    }
  ],
  "samlMetadataUrl": null,
  "extensionProperties": [],
  "objectType": "Application",
  "objectId": "0bdea3fb-5ff7-4b8c-aa2c-6556a4c2ce46",
  "deletionTimestamp": null,
  "createdOnBehalfOf": null,
  "createdObjects": [],
  "manager": null,
  "directReports": [],
  "members": [],
  "memberOf": [],
  "owners": [],
  "ownedObjects": []
}

Solution

  • I don't see an "addIns" property in your manifest, as described here: Configure and update file handlers in Office 365. It might be that this property is just suppressed from the downloaded copy of the manifest, but if you haven't added this property to the manifest, please add it and see if that helps.