-
Notifications
You must be signed in to change notification settings - Fork 450
Upgrade storage client & support Entra identities for storage in more scenarios #3573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I've tried your fork and with a few minor exceptions, it worked perfectly and solved my deployment problem. Thank you!
There are just two small changes I've made to allow working with a Storage Account that has Shared Keys turned off.
{ | ||
var storageAccount = await ArmClient.FindStorageAccount(accountName); | ||
blobContainerClient = new BlobContainerClient(new UriBuilder(storageAccount.Properties.PrimaryEndpoints.Blob) { Path = containerName }.Uri, | ||
new Storage.StorageSharedKeyCredential(accountName, storageAccount.Key.Value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the StorageSharedKeyCredential and use this.Credential instead.
This allows disabling Shared Keys on the storage account altogether.
|
||
return blob.Uri + blobToken; | ||
return blob.GenerateSasUri(sasConstraints).ToString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, to allow disabling Shared Keys on the storage account, return blob.Uri in case managed identity is used.
I would be awesome if this could get merged & released. Making my storage account accessible via managed identity only led me to this PR, due to this not being merged yet I was forced to switch to |
@Azure/azure-functions-worker-owners @mattchenderson PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR upgrades the storage client and supports Entra identities in more scenarios by updating how access tokens are fetched and modifying ARM calls. Key changes include:
- Replacing legacy token retrieval with a chained AzureCliCredential/AzurePowerShellCredential approach.
- Refactoring ARM client usage by renaming ArmClient to CliArmClient and updating all corresponding calls.
- Modifying storage package upload logic to use the new Azure Storage SDK with SAS URI generation and adding a new constant for AzureWebJobsStorageAccountName.
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/Azure.Functions.Cli/Arm/ArmClientExtensions.cs | Introduces storage account lookup using ARM and new record types. |
src/Azure.Functions.Cli/Actions/AzureActions/PublishFunctionAppAction.cs | Updates deployment logic and container upload to use the new storage SDK. |
src/Azure.Functions.Cli/Common/Constants.cs | Adds a constant for AzureWebJobsStorageAccountName. |
src/Azure.Functions.Cli/Actions/AzureActions/BaseAzureAction.cs | Switches to chained credentials and refactors initialization order. |
src/Azure.Functions.Cli/Common/SimpleProgressBar.cs | Changes progress reporting to use IProgress. |
Multiple test files and AzureHelper.cs | Update to reference CliArmClient instead of the legacy ArmClient. |
Comments suppressed due to low confidence (2)
src/Azure.Functions.Cli/Helpers/AzureHelper.cs:1031
- The call to 'ArmClient.FindStorageAccount' appears to use a static reference even though the extension method is defined on an instance of ResourceManager.ArmClient. Consider providing an appropriate ArmClient instance (or using CliArmClient if intended) to ensure proper runtime behavior.
var storageAccount = await ArmClient.FindStorageAccount(accountName);
src/Azure.Functions.Cli/Actions/AzureActions/BaseAzureAction.cs:93
- Since GetAccessToken constructs its TokenRequestContext using ManagementURL (by appending '/.default'), ensure that ManagementURL is always initialized before calling GetAccessToken to avoid potential runtime errors.
if (string.IsNullOrEmpty(ManagementURL)) { ManagementURL = await GetManagementURL(); } if (string.IsNullOrEmpty(AccessToken)) { AccessToken = await GetAccessToken(); }
Issue describing the changes in this PR
Resolves #3376
Pull request checklist
PR overview:
AzureCliCredential
andAzurePowerShellCredential
to fetch an access token instead of the code that calls the CLIsDefaultAzureCredential
to preserve the current behavior, as it might require the user to specify a tenant ID under certain conditionsAzureWebJobsStorage__accountName
in more scenarios: