Fix server-side copy with Managed Identity in AzureBlobStore #944
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fix
NullPointerExceptionwhen performing server-side blob copy operations using Managed Identity with theazureblob-sdkprovider. See also issue #939.Problem
When
AzureBlobStoreis configured with Managed Identity, thecopyBlobmethod fails with:The root cause is that
BlobClientBase.generateSas()requiresStorageSharedKeyCredentialinternally. When theBlobServiceClientis constructed withDefaultAzureCredential(for Managed Identity), no shared key is available, causing theNullPointerException.Solution
The Azure SDK provides an alternative for OAuth-based authentication: User Delegation SAS. This approach:
UserDelegationKeyfromBlobServiceClient.getUserDelegationKey()BlobClientBase.generateUserDelegationSas()instead ofgenerateSas()The fix detects whether shared key credentials are available:
generateSas()(unchanged behavior)generateUserDelegationSas()with a user delegation keyRequirements
When using Managed Identity, the identity must have the RBAC permission:
Microsoft.Storage/storageAccounts/blobServices/generateUserDelegationKey/actionThis permission is included in built-in roles:
Validation
@hermandavid could you validate the change? e.g. by building a custom image. I can support you with that. Would be cool if we can validate this before merging it to master.