Fetch a package from Azure Blob Storage using a managed identity only works in consumption plan
Fetch a package from Azure Blob Storage using a managed identity only works in consumption plan. Not supported in Basic or Premium tiers.
Documentation reference: https://docs.microsoft.com/en-us/azure/azure-functions/run-functions-from-deployment-package#fetch-a-package-from-azure-blob-storage-using-a-managed-identity https://docs.microsoft.com/en-us/azure/app-service/overview-managed-identity?tabs=portal%2Cdotnet#using-the-rest-protocol
I suspect it is because the following environment variables are not available in Kudu:
/home>env | grep IDENTITY_*
IDENTITY_ENDPOINT=[Managed identity has been configured. This value is not viewable in Kudu but is exposed to the app.]
IDENTITY_HEADER=[Managed identity has been configured. This value is not viewable in Kudu but is exposed to the app.]
/home>env | grep ^MSI
MSI_ENDPOINT=[Managed identity has been configured. This value is not viewable in Kudu but is exposed to the app.]
MSI_SECRET=[Managed identity has been configured. This value is not viewable in Kudu but is exposed to the app.]
/home>grep Failed ./LogFiles/*_docker.log | head -1
./LogFiles/2022_06_27_XXXXXX_docker.log:2022-06-27T14:15:12.018Z ERROR - RunFromPackage> Failed to download package from https://XXXXX.blob.core.windows.net/deploy-packages/run-from-package/custom-handler.zip. Return code: 1
/home>env | grep ^WEBSITE_RUN_FROM_PACKAGE
WEBSITE_RUN_FROM_PACKAGE=https://XXXXX.blob.core.windows.net/deploy-packages/run-from-package/custom-handler.zip
WEBSITE_RUN_FROM_PACKAGE_BLOB_MI_RESOURCE_ID=/subscriptions/XXXXX/resourceGroups/XXXXX/providers/Microsoft.ManagedIdentity/userAssignedIdentities/XXXXX
Please provide the following:
- Timestamp: Mon Jun 27 03:59:43 PM UTC 2022
- Function App version: 4
- Region: East US
Expected behavior
Successful deployment from a package from Azure Blob Storage using a managed identity, as when using consumption plan.
Actual behavior
Works only in consumption plan.
Known workarounds
Use the SAS token in WEBSITE_RUN_FROM_PACKAGE.
Related information
Possible related discussions:
https://docs.microsoft.com/en-us/answers/questions/380576/managedidentitycredential-authentication-unavailab.html https://github.com/Azure/azure-sdk-for-python/issues/23406 https://social.msdn.microsoft.com/Forums/azure/en-US/23087180-1820-469d-a771-cff4b6283985/enabling-system-assigned-identity-for-an-app-service-doesnt-populate-msiendpoint-msisecret?forum=windowsazurewebsitespreview
Hi @shinji Could you please provide repro steps?
HI @Ved2806 ,
- Create a Linux Service Plan with Basic o Premium tier.
- Create a Storage Account and container.
- Upload ZIP package with custom handler to container
- Create a User-Assigned Managed Identity.
- Create following role assignements to User-Assigned Managed Identity in Storage Account: "Storage Blob Data Owner", "Storage Account Contributor", "Storage Queue Data Contributor", "Storage Blob Data Contributor", "Storage Table Data Contributor", "Storage Account Key Operator Service Role", "Reader and Data Access",
- Create a Function associated to previously created Service Plan.
- Add User-Assigned Managed Identity to Function.
- Configure Function to authenticate to Blob Storage APIs using a User-Assigned Managed Identity. WEBSITE_RUN_FROM_PACKAGE_BLOB_MI_RESOURCE_ID= User-Assigned Managed Identity ID
- Configure Function with following parameter to run custom handler from a package allocated in Blob Storage Container. WEBSITE_RUN_FROM_PACKAGE= Package URL
Currently results: Function never start correctly.
To make it work just repeat everything and only change to a Linux Service Plan with Consumption tier.
Regards
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
HI @Ved2806 ,
Create a Linux Service Plan with Basic o Premium tier.
Create a Storage Account and container.
Upload ZIP package with custom handler to container
Create a User-Assigned Managed Identity.
Create following role assignements to User-Assigned Managed Identity in Storage Account:
"Storage Blob Data Owner",
"Storage Account Contributor",
"Storage Queue Data Contributor",
"Storage Blob Data Contributor",
"Storage Table Data Contributor",
"Storage Account Key Operator Service Role",
"Reader and Data Access",
Create a Function associated to previously created Service Plan.
Add User-Assigned Managed Identity to Function.
Configure Function to authenticate to Blob Storage APIs using a User-Assigned Managed Identity.
WEBSITE_RUN_FROM_PACKAGE_BLOB_MI_RESOURCE_ID= User-Assigned Managed Identity ID
Configure Function with following parameter to run custom handler from a package allocated in Blob Storage Container.
WEBSITE_RUN_FROM_PACKAGE= Package URL
Currently results: Function never start correctly.
To make it work just repeat everything and only change to a Linux Service Plan with Consumption tier.
Regards