From 403fe17f96c9ef9aa337f1c3a3f7ae9fcf32e2b3 Mon Sep 17 00:00:00 2001 From: Eugene Chuvyrov Date: Tue, 8 Nov 2016 00:00:15 -0800 Subject: [PATCH] Changed Service Principal Creation sequence to comply with newer CLI reqs --- contrib/azure-setup.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/contrib/azure-setup.sh b/contrib/azure-setup.sh index 3202dc3ce..0a317f6b8 100755 --- a/contrib/azure-setup.sh +++ b/contrib/azure-setup.sh @@ -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