How to get clientId and clientsecret for Azure (ARM) deployment template

user2713516 picture user2713516 · Jun 9, 2016 · Viewed 34.9k times · Source

I want to automate my Azure resource management, and I'm using the ARM templates to do so.

If I want to connect to Azure from my C# code (the DeploymentHelper.cs that is generated when downloading an Azure export template).

The code is asking for the following details:

        string subscriptionId = "your-subscription-id";
        string clientId = "your-service-principal-clientId";
        string clientSecret = "your-service-principal-client-secret";
        string resourceGroupName = "resource-group-name";
        string deploymentName = "deployment-name";
        string resourceGroupLocation = "resource-group-location"; // must be specified for creating a new resource group
        string pathToTemplateFile = "path-to-template.json-on-disk";
        string pathToParameterFile = "path-to-parameters.json-on-disk";
        string tenantId = "tenant-id";

I can see the tentantId and subscriptionId via powershell, but I have no clue how to get the clientId and clientsecret, and I cant find any solid instructions on how to get these either.

Answer

Edward Rixon picture Edward Rixon · Jun 9, 2016

Have you created a service principal in AD? If so, you should have these values. If you haven't, follow the msft guide.

https://azure.microsoft.com/en-gb/documentation/articles/resource-group-create-service-principal-portal/