Hello @Zackarias Montell
You have correctly identified the root cause and confirmed that the Function App operates as expected when the SAS token is removed from WEBSITE_RUN_FROM_PACKAGE.
As designed, if WEBSITE_RUN_FROM_PACKAGE contains a SAS URL, Azure Functions will prioritize the token and bypass the configured Managed Identity, even if it has the required permissions. This explains why your manual test—removing the SAS and restarting the app—resulted in the use of Managed Identity, which is the expected behavior.
The Microsoft documentation describes how to use Managed Identity for package deployment, assuming manual management of the ZIP upload and app settings. However, when using Azure DevOps and the AzureFunctionApp@1 task, the task automatically uploads the package and sets WEBSITE_RUN_FROM_PACKAGE to a SAS-based URL, overriding the Managed Identity approach. Currently, there is no option in the task to prevent this.
To utilize Managed Identity as documented, you can:
- Manually upload your ZIP package to a private container in your storage account (e.g., using az storage blob upload).
- Assign the Storage Blob Data Reader role to your Function App’s managed identity, scoped to the appropriate blob or container.
- Configure these application settings:
- WEBSITE_RUN_FROM_PACKAGE: Set to the blob URI without a SAS token.
- WEBSITE_RUN_FROM_PACKAGE_BLOB_MI_RESOURCE_ID: Leave blank or set to "SystemAssigned" for system-assigned identity, or provide the full resource ID for a user-assigned identity.
- Restart the Function App after updating the settings.
- WEBSITE_RUN_FROM_PACKAGE: Set to the blob URI without a SAS token.
This process mirrors your successful manual test and enables automated deployment without relying on a SAS token or the default AzureFunctionApp@1 behavior.
References:
Hope this helps!!