Azure CI to BitBucket Deploy with Managed Identity

David V. Corbin 1 Reputation point
2021-10-27T16:16:53.49+00:00

As the title says... Everything works when I use my identity... I log in, authenticate, setup tokens... all good.

But how to do this for a managed identity????

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
9,010 questions
Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,291 Reputation points Microsoft Employee Moderator
    2021-11-01T23:57:47.537+00:00

    Hi @David V. Corbin ,

    You can create a service principal, with the least set of privileges, with the following the command and use the json output to your secrets in your BitBucket yaml script.

       az ad sp create-for-rbac --name "myAppDeployAuth" --role contributor \  
                                   --scopes /subscriptions/<subscription-id>/resourceGroups/<group-name>/providers/Microsoft.Web/sites/<app-name> \  
                                   --sdk-auth  
    

    ---

    EDIT: I came across https://learn.microsoft.com/en-us/azure/active-directory/saas-apps/atlassian-cloud-tutorial and think this is what you're referring to. A system managed identity isn't going for work for this use case because only Azure services can use it. What I suggest is creating a user identity per the tutorial and assigning that user identity to you Azure resource. Another option you have is configuring a JWT token that your code running on Azure can use.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.