Created
June 7, 2018 14:38
-
-
Save tomzorz/35d795e144d7814fca57ff43c9b435d3 to your computer and use it in GitHub Desktop.
Create Azure Service Principal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set params | |
$subid = '{subscription id here}' | |
$uri = 'http://{uri here}' | |
$pp = '{password here}' | |
$dn = '{display name here}' | |
# ---------------------------------------------- | |
# run code | |
Login-AzureRmAccount -SubscriptionId $subid | |
$password = ConvertTo-SecureString $pp -asplaintext -force | |
$app = New-AzureRmADApplication -DisplayName $dn -HomePage $uri -IdentifierUris $uri -Password $password | |
New-AzureRmADServicePrincipal -ApplicationId $app.ApplicationId | |
# wait 30 sec before executing below | |
New-AzureRmRoleAssignment -RoleDefinitionName Contributor -ServicePrincipalName $app.ApplicationId | |
# your ClientId | |
$app.ApplicationId | |
# your ClientSecret | |
$pp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment