Hi Richard Barraclough,
Welcome to Microsoft Q&A, thanks for posting your query.
The error you are facing "AuthorizationResourceTypeMismatch" is due to your SAS token is not having the correct permissions or resource type that needed for the protection service to interact with the blob storage. Here are the steps to follow to generate a valid SAS token.
Check Permissions:
Navigate to the Shared access signature settings of the storage account as shown in your screenshot.
Verify the allowed permissions include Read, Write, Delete, List and Create. These are important for managing Data Protection keys in Blob Storage.
Correct Resource Types:
Under Allowed Resource types, select Service, Container and Object. This is important, as missing any of these can prevent access for specific level.
Regenerate the SAS token:
Set an appropriate expiry date to avoid frequent interruption. After configuring the permissions and resource types, click Generate SAS and connection string. Copy the generated SAS token and add a "?" at the beginning.
Update the Application Configuration:
Replace the expired SAS token in your code with the new one, in the following format:
services.AddDataProtection()
.PersistKeysToAzureBlobStorage(new Uri(aspNetCoreDataProtectionOptions.BlobUri + "?" + aspNetCoreDataProtectionOptions.SasToken))
.ProtectKeysWithAzureKeyVault(new Uri(aspNetCoreDataProtectionOptions.KeyIdentifier), new DefaultAzureCredential())
.SetApplicationName(applicationName);
This configuration will enable your application to access blob storage using the updated SAS token.
Test the Application:
Restart the application and check if it is starts up successfully without the authorization error.
Consider using managed identity. This approach simplifies authentication, reduce dependency on SAS tokens, and this eliminates the need for regular SAS token renewals, making your setup more secure.
Please let us know if you have any further queries. I’m happy to assist you further.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.