In this article, I’ll show you how to create a SharePoint add-in app (Provider-hosted) for Office 365 and publish your app in Microsoft Azure Web via Visual Studio.
The basic requirements:
- You can use Visual Studio 2013, 2015, or higher
- Install Windows Azure SDK for Visual Studio. You can download it for visual studio 2015 here
- If you don’t have either yet you can get an Office 365 free trial and Azure free.
Connect to your Azure via Visual Studio 2015
In Server Explorer, you right Click on Azure (Windows Azure) and select Connect to Microsoft Azure Subscription.
Create the Azure App Service.
Type a name for your web app (it must be unique) and keep the selected default for Subscription. You can choose an existing group or click on New to create a new one for Resource Group. You also should create a new name for the App Server Plan.
Ok, Refresh and you can see your new App.
If you want to see more details, right-click, and choose Properties.
Create a SharePoint online Add-In App Provider-Host.
Go to menu File and choose New Project.
Select Office/SharePoint and choose the SharePoint Add-in template.
Enter your SharePoint online Developer site collection where you want to deploy your app and choose Provider-hosted.
SharePoint needs the credentials of the user who is authorized to deploy the app.
Choose the type of application project (MVC or Web Form) that you want.
You have an app now and can quickly run to test or debug locally by hitting F5.
Publish your app in Windows Azure.
Make sure that you have an App Service on Windows Azure (see the #item “Create the Azure App Service”).
First, you need to download the publish profile for the app by right-clicking on your App Service in Azure and select Download Publish Profile.
You should see a file with the extension .publishsettings in your download folder.
Next, it’s important that you get a Client ID and Client Secret from SharePoint online. Go to your SharePoint site and append the URL “_layouts/15/appregnew.aspx”
Click on Generate to get your new Client ID and Secret Key. You should view properties in your app service to see the Url and App Domain. Notice it lets you replace the Url with https.
Click on Create. Excellent. Now the information you need to remember for the next step:
In Solution Explorer right-click on your SharePoint App (not Web App) and choose Publish.
Then you create a new profile.
Browse to the .publishsettings file that you downloaded previously.
Choose Finish after you fill Client ID and Client Secret.
Now, the profile you created for your app that contains Client ID and Client Secret. Choose Deploy your web project to continue.
Start Preview if you wish to see the files that will be deployed on Azure.
Congratulations! The web app has published on your Azure.
Next, choose Package the add-in. A message appears to prompt you to change the URL to https.
The .app package can now be uploaded to your app catalog.
Go to your SharePoint developer site. Under Apps in Testing, you can see your app, because it was added when you hit F5 previously. Now you need to remove it.
And then choose New app to deploy.
Choose Trust it and wait a minute.
Launch your app and finally, your app will show on browse.
That’s all! Congratulations, you have successfully published your app in Windows Azure.