Multi tenant app with RBAC enabled writing to StorageAccount using Storage SDK: Server failed to authenticate the request
We want our multi tenant app (using RBAC) write to StorageAccount using Storage SDK. Below is our scenario...
Tenant A: Created a application (clientId A1)
Application Permissions screen capture
Tenant B: Consented the application & granted 'Storage Blob Data Contributor' permission to A1 on StorageAccount S1
We are getting below error when tenant A tries upload a files to S1
I am getting below error...
Azure.RequestFailedException: Server failed to authenticate the request. Please refer to the information in the www-authenticate header.
RequestId:7a83e2bf-501e-0060-56b3-d5e372000000
Time:2020-12-19T03:06:42.5400377Z
Status: 401 (Server failed to authenticate the request. Please refer to the information in the www-authenticate header.)
ErrorCode: InvalidAuthenticationInfo
Headers:
Server: Microsoft-HTTPAPI/2.0
Below is our code snippet
BlobServiceClient blobServiceClient = new BlobServiceClient(
new Uri($"https://{options.StorageAccount}.blob.core.windows.net"),
credential);
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(
options.ContainerName);
containerClient.CreateIfNotExists(PublicAccessType.BlobContainer);