Skip to content

Instantly share code, notes, and snippets.

@monester
Last active September 26, 2018 06:04
Show Gist options
  • Save monester/aab133d0521e766361332bbd870ab4fa to your computer and use it in GitHub Desktop.
Save monester/aab133d0521e766361332bbd870ab4fa to your computer and use it in GitHub Desktop.
# create service-principal
az ad sp create-for-rbac --query "{ client_id: appId, client_secret: password, tenant_id: tenant }"
cat >~/.azure/credentials <<EOF
# az ad sp create-for-rbac --query "{ client_id: appId, client_secret: password, tenant_id: tenant }"
[default]
# subscription
subscription_id=
# tenant
tenant=
# user credentials
client_id=
secret=
EOF
cat cred.json | gawk '(NR>1 && NR<5){s=gensub(/.*"(client_|)(client_id|secret|tenant)(_id|)": "(.*)".*/, "\\2=\\4", "g"); print s}' >> ~/.azure/credentials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment