Demo Setup¶
The demo has a number of piece to setup and this guide will step through each. The steps are ordered as some information is needed in subsequent steps or some actions need happen ahead of others. Please follow the guide to ensure your solution is properly configured.
Sections¶
- Create Service Bus Queue
- Create Azure App Function
- Configure AAD App Settings
- Configure Local Settings
- Deploy Azure Function App
- Update SPFx Solution
- Deploy Solution
- Next Steps
Create Service Bus Queue¶
- In Azure Portal select "Create a resource"
-
Search for "service bus" and select the "Service Bus" option, then "Create"
-
Select the subscription, resource group, namespace, and location then select "Review + Create"
- Review your choices and select "Create"
- Once provisioning is complete select "Go to resource" to load the resource page
- On the left, select "Queues" under the "Entities" section
-
Select "+ Queue" at the top
-
Provide a name for the new queue and note it for later. You may adjust other settings as needed but the remaining defaults are fine for this demo setup. Once ready select "Create"
- Once created select the name of the new queue to open the details screen
- On the left, select the "Shared access policies" under the "Settings" section
- Select "+ Add" at the top
-
Give the policy a name and choose the "Send" and "Listen" options and select "Create"
-
Once created select the policy to expose the keys and connection strings. Copy the value of "Primary Connection String".
-
Paste it into a text editor and remove everything after and including the last ";". Note this edited connection string for later.
Endpoint=sb://{sb-name}.servicebus.windows.net/;SharedAccessKeyName={key-name};SharedAccessKey={shared-key};EntityPath={path}
becomes:
Endpoint=sb://{sb-name}.servicebus.windows.net/;SharedAccessKeyName={key-name};SharedAccessKey={shared-key}
From this section you should record:
- Queue Name (step 8)
- Edited Queue Connection String (step 14)
Create Azure Functions App¶
- In Azure Portal select "Create a resource"
-
Search for "function app" and select the "Function App" option, then "Create"
-
Select a subscription, resource group, name, and region. For the remaining options:
- Publish: Code
- Runtime stack: Node.js
- Version: 14 LTS
- Select "Review + Create" as we will accept the remaining defaults. Ensure the options are correct and select "Create"
- Once provisioning is complete select "Go to resource" to load the resource page
- On the left, select "Authentication" under the "Settings" section
-
Select "Add identity provider"
-
In the dropdown select "Microsoft". Accept the defaults as shown below and select "Next: permissions".
-
Select "+ Add permission" and choose "User.Read", "offline_access", "openid", and "Files.ReadWrite.All" then select "Add"
-
Once the identity provider is created, select the "edit" pencil icon and remove the "v2.0" from the end of the "Issuer URL" value, leaving the final "/" in place. The value should be "https://sts.windows.net/{your-tenant-id}/"
-
At this point, navigate to the url of your function you should be prompted to login and consent to the app permissions. If successful you will be land on a screen similar to below. The url will be of the form https://{app-name}.azurewebsites.net. This step is required to establish the enterprise app entry used later for app permissions approval.
-
Navigate to "Configuration" under the "Settings" section of the function app. You need to add two keys whose values both come from the previous section on setting up the service bus. Once both are added select "Save" from at the top and "Continue" when prompted to update the app with the new settings.
- ServiceBusConnection = The edited service bus connection
- ServiceBusQueueName = The name of the queue
- MICROSOFT_PROVIDER_AUTHENTICATION_APPID = The App ID of the AAD app associated with the function
-
Navigate to "CORS" under "API". Enter a "" for allowed origins and select "Save" at the top. Depending on your needs you can use this setting to limit what SP sites can call your API. The value of "" allows all domains to call the service, acceptable for the demo.
From this section you should record:
- Azure Function App Url (step 11)
Configure AAD App Settings¶
- In the settings of the function app created in the previous section, select "Authentication" under the "Settings" section
- Copy the "Display name" and "Application (client) ID" for later
- Navigate to "Expose an API" under the "Manage" section
- Update the Application ID URI and set the value to match the URL of the Azure function and select save. The value will be https://{function-app-name}.azurewebsites.net
- Navigate to "API Permissions" under the "Manage" section
- Select the "Grant Admin consent" option to consent to all the permissions for the tenant if not already consented.
From this section you should record:
- Azure Application Name (step 2)
- Azure Application ID (step 2)
Configure Local Settings¶
To ensure smooth publishing of the application you need to create a "local.settings.json" file within the "azure-functions" folder.
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "node",
"AzureWebJobsStorage": "UseDevelopmentStorage=true"
}
Deploy Azure Function App¶
This section uses the Azure CLI to conduct the deployment. There are many ways to deploy apps to Azure and you should use the methods most comfortable to you.
You also need to install the azure function tools v3 using
npm i -g azure-functions-core-tools@3 --unsafe-perm true
- Open a command window and navigate to the project folder "azure-function"
- Enter
az login
to login to the Azure instance - Run
npm run build
- Run
func azure functionapp publish {app-name}
- Within the Azure Portal, ensure the app is running and there are no deployment errors
Update SPFx Solution¶
- Open the solution in the "spfx-list-view-command" folder of the "list-view-service-integration" sample
-
Edit the "./config/package-solution.json" file to include the "webApiPermissionRequests" section. Replace {app-name} with the name of your application from the previous section.
"webApiPermissionRequests": [ { "resource": "{app-name}", "scope": "user_impersonation" }, { "resource": "Windows Azure Active Directory", "scope": "User.Read" } ],
-
Update "./sharepoint/assets/ClientSideInstance.xml" and "./sharepoint/assets/elements.xml" changing the {app-name} and {app-id} values to those of your function app and backing AAD application.
- Update "./config/serve.json" changing the value of pageUrl to point to a document library in your development tenant, also update the properties for both serve configurations to set the apiAbsUrl and appId values.
- Finally, update "./src/extensions/contoso/ContosoCommandSet.manifest.json" updating the value "https://{app-name}.azurewebsites.net/api/IconServer" with your app name.
Deploy Solution¶
Follow the docs to deploy the solution and approve the permissions in the SharePoint admin site for the API.
Next Steps¶
At this point the solution is configured for testing in your local environment. While testing the expected behavior will follow the flow outlined in the overview page.