3

I am trying to write an ARM template that can create a service principal on Azure with all the specified permissions. The end goal is to automate this process and create n number of service principals using the template. Is there a way to do this? Any help is much appreciated, thanks!

KGosalia
  • 39
  • 1
  • 5

3 Answers3

1

As @silent said is it not possible to add it via ARM templates.

BUT this is a very common case to use a combination of ARM templates and Powershell or CLI. This will give you more flexibility when creating resources, you should consider that. Mixing ARM templates with the script will solve your problem.

Refs:

https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-cli https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-powershell https://learn.microsoft.com/en-us/azure/active-directory/develop/howto-authenticate-service-principal-powershell

Tomasz Kaniewski
  • 1,065
  • 8
  • 16
0

No, this is not possible. You can create the service principle only using other tools like Azure CLI.

What you can do is to add a role assignment to an existing SP using ARM templates: https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-template

silent
  • 14,494
  • 4
  • 46
  • 86
0

ARM Template wont be able to create a service principal. What You can do is write a PowerShell script to create a single service principal and then parameterize it to use it as a function to create multiple Service Principals by passing different parameters to the same function.