0
votes

I want to use a service principal to deploy a single ARM template to our Azure account.

I cannot find documentation for how to grant the least possible privilege, but it appears the only way to make this work is to grant contributor on the subscription.

Is there a way to limit the role on my service principal to only deploy ARM Templates or at the very least limit it to a single resource group?

2

2 Answers

2
votes

actually, for each template you can figure out the minimum possible permissions by looking at the template, they would be resourcetype + /write. and the permissions to create deployments Microsoft.Resources/deployments/write.

but its really easier to just give a person contributor over the resource group. if you are concerned about security you can use Privileged Identity Management in Azure AD

0
votes

In the access control (IAM) section under a Resource group you can make the service principle you created 'Contributer'. this will make sure that that user can only deploy resources within that resource group. This way the account doesn't need any permissions on the subscription level.

When you go to the Access Control section click Add, and select "Add role Assignment" enter image description here

In the panel that shows you can select the role "Contributer" and lookup the Service principle you created. Then click 'Save' to finish and you should be good to go

I tend to make service connections (with separate Service Principles) in DevOps per environment this makes it clear what resources you can touch and prevents people from accidentally deploying to incorrect locations from a pipeline because the typed in the wrong resource group name.