In the previous article, you saw how to create, configure and deploy remote add-in Web to Azure.
In this article, you will learn how to deploy the provider hosted app to SharePoint Online. From the solution structure, right click the App Manifest file of ‘OfficeProviderHostedAddIn’ and select View Code.
This will show the page, where we can set the start page and the permission strings.
Replace the start page with the URL of Azure Web app (https://officeproviderhostedadd-in.azurewebsites.net/), we had created in the first article. Ensure you add Https to the URL. Now, replace the ClientId value ‘*’ with the ClientId, which was created in the App Registration page in the previous article.
Ensure https is added to the URL, else once we upload the package to the App Catalog, it might be shown as Invalid.
Now, right click the addin and publish the addin.
This will open up the addin publishing page. If the current profile has a Yellow highlighted exclamation mark, click Edit button.
Make sure you have added the Client ID and Client Secret. Once they are filled up, Yellow exclamation warning will go off.
Click on package to add-in.
Enter the URL of Azure Web app we had created in the previous article and the client Id of the app.
Make sure that https are used in the URL, else we will get the warning error, given below-
On successful packaging, it will create the .app file in the local file system.
Now, we have to upload the .app file to the app catalog of SharePoint Online. If an app catalog does not exist, you can check the article here to see how to create an app catalog. Once you are within the Apps Catalog, click Apps for SharePoint.
Click Upload and it will open up the file upload Window. Navigate to the app location and upload the .app file.
The app file is now uploaded to the Apps Catalog.
Now, we can add the recently uploaded app to the site by going to the site contents of the particular site. Click ‘From Your Organization’. This will show the recently uploaded app in the list. Click it.
It will ask whether you trust the app. Click Trust it.
This will start adding the provider hosted add-in to the site contents.
Finally, it has been added to the list of apps present within the site.
When we click on the app, it will go to the app redirect page and it will be navigated to the remote Azure Web app.
As you can see in the Browser address bar, the redirection has been completed and Azure Web app has come up in the Browser. Here, we can see the current logged in user name, which was fetched, using controller and was displayed in the view of the MVC project. We can add more logic to MVC project, as per the requirement.
Summary - Thus, we saw how to deploy a provider hosted add-in to SharePoint Online in Office 365, using Azure.