I'm testing an Azure function that has a blob trigger then writes a message in a message queue. I have "Allow storage account key access" disabled as we want to use Managed identities to access all resources. Problem is that when the code below is triggered gives an error:
2024-12-12T01:00:08Z [Verbose] Host instance '5xxxxxxxx' failed to acquire host lock lease: Azure.Storage.Blobs: Service request failed.
Status: 403 (Key based authentication is not permitted on this storage account.)
ErrorCode: KeyBasedAuthenticationNotPermitted"
Permisisons are given to the function MI on the storage account as Storage Blob data contributor and Storage Queue data contributor. The code is as fololos, from a sample provided by MSFT.:
import logging
import json
import base64
import time
import azure.functions as func
from azure.identity import DefaultAzureCredential
from azure.storage.queue import QueueServiceClient
app = func.FunctionApp()
@app.blob_trigger(arg_name="myblob", path="ccr1/{name}",
connection="AzureWebJobsStorage")
def blob_trigger(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob"
f"Name: {myblob.name}"
f"Blob Size: {myblob.length} bytes")
try:
message_data = {
"file_path": myblob.name
}
blob_name = myblob.name.split('/')[-1]
if blob_name.endswith('.pdf'):
logging.info(f"Extracted PDF name: {blob_name}")
ccr_e2e_report(blob_name) # Send the PDF name to another function
else:
logging.warning("The blob is not a PDF file.")
except Exception as e:
logging.info(e)
# Example function to send data to
def ccr_e2e_report(pdf_name: str):
logging.info(f"Generating CAR report for : {pdf_name}")
time.sleep(20)
logging.info(f"Report generation complete: {pdf_name}")
@app.route(route="http_trigger", auth_level=func.AuthLevel.ANONYMOUS)
def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
cnt = int(req.params.get('count'))
if cnt:
for number in range(1, cnt + 1):
message_data = {
"file_path": "None",
"file_uri": "None",
"file_metadata": f"{cnt}"
}
# Convert the Python dictionary to a JSON string
message_json = json.dumps(message_data)
send_message_to_queue("ccrqueue", message_json)
return func.HttpResponse(f"Submitted: {cnt} Messages. This HTTP triggered function executed successfully.")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized resonse.",
status_code=200
)
All my research tells me they support MI access to storage accounts from a function app but perhapsIm missing something obvious here, any info would eb great. Thanks









AzureWebJobsStorageto use Managed Identity, add "centralizedManagedIdentity": true in host.json, and ensure the Function App's MI hasBlob Data Contributorrole.