[Python] Fetch Azure Managed Identity from within Function

Discussão em 'Python' iniciado por Stack, Fevereiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am using Azure Managed Identity feature for my python Azure Functions App and would like to be able to fetch currently assigned Client ID from within the Function App itself.

    Search through documentation and azure-identity python sources did not give result I would expect.

    Maybe I could:

    1. Query Azure Instance Metadata Service myself to get this ID. (not really happy with this option)
    2. Provision it as env variable during ARM deployment stage/ or by hands later on. (seems good and efficient, but not sure what is the best practice here)

    UPDATE

    Managed o get it working with ARM template and env variable

    1. Deploys FunctionApp with System Identity
    2. Provisions System Identity as env variable of this same FunctionApp

    Idea is to use Microsoft.Resources/deployments subtemplate to update Function App configuration with:

    {
    "name": "AZURE_CLIENT_ID",
    "value": "[reference(resourceId('Microsoft.Web/sites', variables('appName')), '2019-08-01', 'full').identity.principalId]"
    },

    Continue reading...

Compartilhe esta Página