Search code examples
azureazure-functionsidentity

Impossible to assign a managed identity to my Azure function


I have been trying to assign a user assigned managed identity or system assigned managed identity, to my Azure function.

However whenever I try and and assign a managed identity, nothing happens. It keeps telling me "Added 1 identity to function" with a green checkmark, both with system assigned and user assigned, but then it reverts back immediately.

I have tried recreating my function (with the same name and a different name) and waiting 1 and 2 days between assigning an identity, with no effect.

I have made a video showing the error https://youtu.be/W9UsYXcsnmg

The weird part about it, is I am able to assign identities to all my other functions, which use the same region, consumption plan and resource group.

I have also made sure it is not a privilege problem, as my Azure administrator has the same issue, but only for this "function".

Has anybody encountered this before or do you have any possible solutions. Right now the function can not connect to our database.


Solution

  • @Thomas, helped me answer my question, so if anyone ever run into the same problem as me, here is what I did.

    1. Exported a template from a function that has an identity attached
    2. Copied the "identity" part from that template
    3. Exported the template from the function that did not work
    4. Deleted the function from the Azure platform
    5. Inserted the "identity" part from the original template into the new function template
    6. Ran a custom deployment with the new template, that is the original function with the new "identity" part