Changed Service Principal Creation sequence to comply with newer CLI reqs

This commit is contained in:
Eugene Chuvyrov 2016-11-08 00:00:15 -08:00
parent ab48ed3fe6
commit 403fe17f96
1 changed files with 15 additions and 1 deletions

View File

@ -11,6 +11,7 @@ azure_subscription_id= # Derived from the account after login
azure_tenant_id= # Derived from the account after login
location=
azure_object_id=
azureversion=
showhelp() {
echo "azure-setup"
@ -156,7 +157,20 @@ createApplication() {
createServicePrincipal() {
echo "==> Creating service principal"
azure ad sp create $azure_client_id
# Azure CLI 0.10.2 introduced a breaking change, where appId must be supplied with the -a switch
# prior version accepted appId as the only parameter without a switch
newer_syntax = false
IFS='.' read -ra azureversionsemver <<< "$azureversion"
if [[ ${azureversionsemver[0]} -ge 0 && ${azureversionsemver[1]} -ge 10 && ${azureversionsemver[2]} -ge 2]]; then
newer_syntax = true
fi
if [newer_syntax -eq true ]; then
azure ad sp create -a $azure_client_id
else
azure ad sp create $azure_client_id
fi
if [ $? -ne 0 ]; then
echo "Error creating service principal: $azure_client_id"
exit 1