azureazure-functionsazure-managed-identityazure-blob-trigger

How to trigger blob function with user assigned identity


I have created a blob trigger azure function which uses connection string in the code at the moment.

local.settings.json

enter image description here

public static class BlobTrigger_Fun
{
    [FunctionName("BlobTrigger_Fun")]
    public static void Run([BlobTrigger("democontainerazure/{name}", Connection = "AzureWebJobsStorage")]Stream myBlob, string name, ILogger log)
    {
        log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
    }
}

I want to use managed identity to avoid use of connection string in the code.


Solution

  • No, you can't.

    The MSI(managed identity) is not for such usage, it is just used for authenticating to azure services that support Azure AD authentication, the AzureWebJobsStorage is used for azure function runtime, in the function app, the property must be specified as an app setting in the site configuration.