Created
July 14, 2021 17:42
-
-
Save GordonBeeming/e1b1501606ca84a1063a685b0a06a92b to your computer and use it in GitHub Desktop.
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
az login | |
$ResourceGroupName = "mvpdays-rg" | |
az account list --output table | |
az account set --subscription "MVP - Dev Tech" | |
$CurrentAccount = az account show | Out-string | ConvertFrom-Json | |
$SubscriptionId = $CurrentAccount.id | |
$DeploymentServicePrincipalName = "$($ResourceGroupName)SP" | |
# Create a service principal | |
$DeploymentServicePrincipalInfo = az ad sp create-for-rbac --name $DeploymentServicePrincipalName --role contributor --scopes "/subscriptions/$($SubscriptionId)/resourceGroups/$ResourceGroupName" --sdk-auth | Out-string | ConvertFrom-Json | |
# New github secrets | |
@" | |
# AZURE_CREDENTIALS | |
$($DeploymentServicePrincipalInfo | ConvertTo-Json) | |
# SP_CLIENTID | |
$($DeploymentServicePrincipalInfo.clientId) | |
# SP_CLIENTSECRET | |
$($DeploymentServicePrincipalInfo.clientSecret) | |
# RESOURCE_GROUP | |
$($ResourceGroupName) | |
"@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment