Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GordonBeeming/e1b1501606ca84a1063a685b0a06a92b to your computer and use it in GitHub Desktop.
Save GordonBeeming/e1b1501606ca84a1063a685b0a06a92b to your computer and use it in GitHub Desktop.
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