admin管理员组

文章数量:1336414

Anyone else having a problem to let durable functions runtime get connection to Azure Storage Account? When you are running Local environment on your VS Code.

For me it is stuck on that and after many many attempts it finally works but this can happen for every request. enter image description here

When function is finally invoked then the internal DefaultAzureCredential() is working smoothly. I have no idea which method Durable Functions use I tried to look from the Source code but could not find that logic.

But based on the documentation () it tries to get a token from the following locations, in the said order, for access to your Azure resources:

  • A local cache shared between Microsoft applications
  • The current user context in Visual Studio
  • The current user context in Visual Studio Code
  • The current user context in the Azure CLI

I am using PIM account, I have local account.... where I use Teams/Outlook/Devops/ etc...

installed software/other:

Azure Func Core Tools Visual Studio Code Python 3.11 PIM Cloud account

az account clear az login az set subscription then there was some command to disable the WAM and I have tried that aswell.

Any help would be appreciated!

-YourCSVman

I have tried to log out, clear cache -> login again, set subscription to the one where storage account lays but no progress. Also I have tried to func host start --verbose from just command line and not inside VS Code Also I have Logged in with my PIM Cloud account in Azure.

Anyone else having a problem to let durable functions runtime get connection to Azure Storage Account? When you are running Local environment on your VS Code.

For me it is stuck on that and after many many attempts it finally works but this can happen for every request. enter image description here

When function is finally invoked then the internal DefaultAzureCredential() is working smoothly. I have no idea which method Durable Functions use I tried to look from the Source code but could not find that logic.

But based on the documentation (https://learn.microsoft/en-us/azure/azure-functions/durable/durable-functions-configure-managed-identity) it tries to get a token from the following locations, in the said order, for access to your Azure resources:

  • A local cache shared between Microsoft applications
  • The current user context in Visual Studio
  • The current user context in Visual Studio Code
  • The current user context in the Azure CLI

I am using PIM account, I have local account.... where I use Teams/Outlook/Devops/ etc...

installed software/other:

Azure Func Core Tools Visual Studio Code Python 3.11 PIM Cloud account

az account clear az login az set subscription then there was some command to disable the WAM and I have tried that aswell.

Any help would be appreciated!

-YourCSVman

I have tried to log out, clear cache -> login again, set subscription to the one where storage account lays but no progress. Also I have tried to func host start --verbose from just command line and not inside VS Code Also I have Logged in with my PIM Cloud account in Azure.

Share edited Nov 22, 2024 at 6:32 Voi Se asked Nov 19, 2024 at 19:33 Voi SeVoi Se 11 bronze badge 2
  • Please provide your function code. – Pravallika KV Commented Nov 21, 2024 at 3:35
  • Is the issue resolved? – Pravallika KV Commented Dec 3, 2024 at 11:16
Add a comment  | 

1 Answer 1

Reset to default 0

Follow below steps to configure Durable Functions with managed identity, refer the blog.

  • Create a function app and enable managed identity. I have enabled System Assigned Managed Identity.
  • Navigate to the interlinked storage account=>Access Control(IAM)=>Grant Storage Account Contributor,Storage Blob Data Contributor role to the function app's managed identity.

Add AzureWebJobsStorage__accountName: <Storage_Account_Name> under FunctionApp=>Settings=>Environment Variables=>App Settings:

Code Snippet:

import logging
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient

def main(name: str) -> str:
   logging.info(f"Listing blobs for: {name}")
   credential = DefaultAzureCredential()
   blob_service_client = BlobServiceClient(account_url="https://<storage-account-name>.blob.core.windows/", credential=credential)
   container_client = blob_service_client.get_container_client("your-container-name")
   blob_list = container_client.list_blobs()
   blob_names = [blob.name for blob in blob_list]
   return f"Blobs for {name}: {blob_names}"

Output:

Logs:

本文标签: