CRUD operations on Provider Hosted SharePoint Add-In to Azure SQL Database

Hi All,

This post is about connecting a SharePoint provider hosted add-in deployed on Azure to a Azure SQL DB for performing basic CRUD operations.

Prerequisites:

  • Microsoft Azure account.
  • Office 365 account
  • Visual Studio 2015/2017 with SharePoint extensions.
  • A empty provider hosted add-in with ACS mode created and deployed on an Azure web app.

Steps:

  • Create Azure SQL DB:
    • Within Azure portal, click New –> Databases –> SQL Database
    • Enter SQL server details.

1

2

  • Update DB server firewall to allow client IP access to the DB
    • Go to list of DBs in Azure, select the current DB – Select ‘Set server firewall’
    • Hit ‘Add client IP’ and then hit Save button.

3

4

  • Modify Provider hosted add-in to create model  from newly created DB:
    • Within project, go to Project –> Models –> Right click add new item. Select ADO.NET Entity data model from Data tab.
    • Select EF Designer from Database option to choose model contents
    • Provide correct Azure connection details to establish the correct connection with newly created Azure SQL DB.
      5
  • Modify Provider hosted add-in to create controller from newly created DB:
    • Within project, go to Project –> Controllers –> Right click add controller 

      910

  • Next add link in the layouts page for user to click from the application.

11

Next when running the SharePoint App, and clicking Customers link, you should be able to see all the data on the screen as shown below:

12

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s