Create a SharePoint connection
The Electronic Invoicing service can read files from Microsoft SharePoint folders and upload files to SharePoint. To ensure that Electronic invoicing can access a specific SharePoint site, you must provide the site credentials to the Electronic Invoicing service. Additionally, to ensure that the credentials are securely stored, don't provide them directly. Instead, store them in an Azure key vault, and provide a Key Vault secret.
Grant access to a SharePoint folder
Create an app registration in the tenant where the Dynamics 365 Finance environment is installed.
- Sign in to the Azure portal.
- Go to App registrations.
- Select New registration.
- Enter a name, such as SharePoint App for Electronic Invoicing, and complete the registration.
- Select the new app registration.
- On the Authentication tab, enable the Allow public client flows option.
- On the Certificates & secrets tab, select New client secret to create a client secret.
- Copy the value of the secret that was created.
Follow these guidelines:
- Don't use the same app registration for different services.
- Follow the password policy recommendations.
- Set up rotation of passwords. During rotation, create a new client secret for the app registration, update the key vault, and then delete the old secret.
Save the App Registration secret and Application (client) ID values as two new secrets in the key vault in the setup of your Electronic invoicing parameters.
Add the secrets that you created to the Key Vault parameters in the setup of your Electronic invoicing parameters. For more information, see Configure Electronic invoicing parameters.
In the Azure portal, grant access to SharePoint. This step should be completed by the tenant administrator.
Select the app registration that you created.
On the API permissions tab, select Add a permission.
Select Microsoft graph (Application permissions) > Sites.Selected.
Select Grant admin consent for <user name>.
Review the Status field to make sure that permissions are granted.
Open Graph Explorer, and sign in.
In the left pane, on the Sample queries tab, under SharePoint Sites, select get SharePoint site based on relative path of the site.
Fill in the {host-name} and {server-relative-path} parameters. For example, fill in
<domain>.sharepoint.com
for {host-name} andsites/<siteName>
for {server-relative-path}.Note
For the default website, leave the {server-relative-path} parameter blank.
Select Run query, and save the result.
Configure the following query.
POST https://graph.microsoft.com/v1.0/sites/{site-id}/permissions
In this query, {site-id} is the value of the id node from the previous query response.
Here's the request body.
{ "roles": [ "read", "write" ], "grantedToIdentities": [ { "application": { "id": "{app-id}", "displayName": "{app-name}" } } ] }
In this request body, {app-id} is the Application (client) ID value, and {app-name} is the Application name value.
On the Modify permissions tab, select Open the permissions panel, and then select Sites > Sites.FullControl.All > Consent.
Select Run query.
The Electronic Invoicing service now has access to your SharePoint site.