From fdbb7a0b3fe53ac1f1150e0cd2f2709050f7923b Mon Sep 17 00:00:00 2001 From: Eugene Chuvyrov Date: Mon, 7 Nov 2016 23:02:05 -0800 Subject: [PATCH 1/9] Removed Azure CLI version checking --- contrib/azure-setup.sh | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/contrib/azure-setup.sh b/contrib/azure-setup.sh index 9d2843160..810740fd8 100755 --- a/contrib/azure-setup.sh +++ b/contrib/azure-setup.sh @@ -64,28 +64,7 @@ requirements() { echo "jq is missing. Please install jq from" echo "https://stedolan.github.io/jq/" fi - - # azure-cli 0.10.5 includes a breaking change - # warn if using an incompatible azure-cli version - # This is just a work around until a more appropriate fix is available - supported_version=true - IFS='.' read -ra azureversionsemver <<< "$azureversion" - if [ ${azureversionsemver[0]} -gt 0 ]; then - supported_version=false - fi - if [ ${azureversionsemver[1]} -gt 10 ]; then - supported_version=false - fi - if [ ${azureversionsemver[2]} -gt 4 ]; then - supported_version=false - fi - echo "supported_version is $supported_version" - if [ "${supported_version}" = false ]; then - echo "Error: azure-cli must be 0.10.4 or older, see http://bit.ly/2etirbM" - exit 1 - fi - if [ $found -lt 2 ]; then exit 1 fi From a5c6d3743e89a8c9b8aee2571d20e23f024040fb Mon Sep 17 00:00:00 2001 From: Eugene Chuvyrov Date: Mon, 7 Nov 2016 23:14:15 -0800 Subject: [PATCH 2/9] Changed Service Principal Creation sequence to comply with newer CLI reqs --- contrib/azure-setup.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/contrib/azure-setup.sh b/contrib/azure-setup.sh index 810740fd8..b172f2c8c 100755 --- a/contrib/azure-setup.sh +++ b/contrib/azure-setup.sh @@ -64,7 +64,7 @@ requirements() { echo "jq is missing. Please install jq from" echo "https://stedolan.github.io/jq/" fi - + if [ $found -lt 2 ]; then exit 1 fi @@ -145,10 +145,18 @@ createStorageAccount() { fi } +createApplication() { + echo "==> Creating application" + azure_client_id=$(azure ad app create -n $meta_name -i http://$meta_name --home-page http://$meta_name -p $azure_client_secret --json | jq -r .appId) + if [ $? -ne 0 ]; then + echo "Error creating application: $meta_name @ http://$meta_name" + exit 1 + fi +} + createServicePrincipal() { echo "==> Creating service principal" - azure_object_id=$(azure ad sp create -n $meta_name --home-page http://$meta_name --identifier-uris http://$meta_name/example -p $azure_client_secret --json | jq -r .objectId) - azure_client_id=$(azure ad app show -c $meta_name --json | jq -r .[0].appId) + azure ad sp create $azure_client_id if [ $? -ne 0 ]; then echo "Error creating service principal: $azure_client_id" exit 1 From ab48ed3fe621d3aa89dc24d29a8f1b88fc4f12c3 Mon Sep 17 00:00:00 2001 From: Eugene Chuvyrov Date: Mon, 7 Nov 2016 23:18:10 -0800 Subject: [PATCH 3/9] Changed Service Principal Creation sequence to comply with newer CLI reqs --- contrib/azure-setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/azure-setup.sh b/contrib/azure-setup.sh index b172f2c8c..3202dc3ce 100755 --- a/contrib/azure-setup.sh +++ b/contrib/azure-setup.sh @@ -209,6 +209,8 @@ setup() { sleep 5 createStorageAccount sleep 5 + createApplication + sleep 5 createServicePrincipal sleep 5 createPermissions From 403fe17f96c9ef9aa337f1c3a3f7ae9fcf32e2b3 Mon Sep 17 00:00:00 2001 From: Eugene Chuvyrov Date: Tue, 8 Nov 2016 00:00:15 -0800 Subject: [PATCH 4/9] 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 From eb75dbb693af12041a88b04596bdb5935d1fbcf8 Mon Sep 17 00:00:00 2001 From: Eugene Chuvyrov Date: Tue, 8 Nov 2016 00:02:31 -0800 Subject: [PATCH 5/9] Changed Service Principal Creation sequence to comply with newer CLI reqs --- contrib/azure-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/azure-setup.sh b/contrib/azure-setup.sh index 0a317f6b8..a766ad9b4 100755 --- a/contrib/azure-setup.sh +++ b/contrib/azure-setup.sh @@ -165,7 +165,7 @@ createServicePrincipal() { newer_syntax = true fi - if [newer_syntax -eq true ]; then + if [ "${newer_syntax}" = true ]; then azure ad sp create -a $azure_client_id else azure ad sp create $azure_client_id From 3ccbb6ca91f3e2f1c97b245e1fc362cf76485fe6 Mon Sep 17 00:00:00 2001 From: Eugene Chuvyrov Date: Tue, 8 Nov 2016 00:05:20 -0800 Subject: [PATCH 6/9] Changed Service Principal Creation sequence to comply with newer CLI reqs --- contrib/azure-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/azure-setup.sh b/contrib/azure-setup.sh index a766ad9b4..287edfd3e 100755 --- a/contrib/azure-setup.sh +++ b/contrib/azure-setup.sh @@ -161,7 +161,7 @@ createServicePrincipal() { # 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 + if [ ${azureversionsemver[0]} -ge 0 ] && [ ${azureversionsemver[1]} -ge 10 ] && [ ${azureversionsemver[2]} -ge 2 ]; then newer_syntax = true fi From f7c6180ff7c054b9d67f3329fb87d7b001474a67 Mon Sep 17 00:00:00 2001 From: Eugene Chuvyrov Date: Tue, 8 Nov 2016 00:09:23 -0800 Subject: [PATCH 7/9] Changed Service Principal Creation sequence to comply with newer CLI reqs --- contrib/azure-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/azure-setup.sh b/contrib/azure-setup.sh index 287edfd3e..43be0ea9f 100755 --- a/contrib/azure-setup.sh +++ b/contrib/azure-setup.sh @@ -159,10 +159,10 @@ createServicePrincipal() { echo "==> Creating service principal" # 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 + 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 + newer_syntax=true fi if [ "${newer_syntax}" = true ]; then From 9f3393f7e97576a7276c72f906f2f534bbf3704f Mon Sep 17 00:00:00 2001 From: Eugene Chuvyrov Date: Tue, 8 Nov 2016 00:16:07 -0800 Subject: [PATCH 8/9] Changed Service Principal Creation sequence to comply with newer CLI reqs --- contrib/azure-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/azure-setup.sh b/contrib/azure-setup.sh index 43be0ea9f..0d8f8a784 100755 --- a/contrib/azure-setup.sh +++ b/contrib/azure-setup.sh @@ -166,9 +166,9 @@ createServicePrincipal() { fi if [ "${newer_syntax}" = true ]; then - azure ad sp create -a $azure_client_id + azure_object_id=$(azure ad sp create -a $azure_client_id | jq -r .objectId) else - azure ad sp create $azure_client_id + azure_object_id=$(azure ad sp create $azure_client_id | jq -r .objectId) fi if [ $? -ne 0 ]; then From e343ad238b4ce5ddeaa8ed659b1718183e09c0cf Mon Sep 17 00:00:00 2001 From: Eugene Chuvyrov Date: Tue, 8 Nov 2016 00:20:45 -0800 Subject: [PATCH 9/9] Changed Service Principal Creation sequence to comply with newer CLI reqs --- contrib/azure-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/azure-setup.sh b/contrib/azure-setup.sh index 0d8f8a784..2e5671bef 100755 --- a/contrib/azure-setup.sh +++ b/contrib/azure-setup.sh @@ -166,9 +166,9 @@ createServicePrincipal() { fi if [ "${newer_syntax}" = true ]; then - azure_object_id=$(azure ad sp create -a $azure_client_id | jq -r .objectId) + azure_object_id=$(azure ad sp create -a $azure_client_id --json | jq -r .objectId) else - azure_object_id=$(azure ad sp create $azure_client_id | jq -r .objectId) + azure_object_id=$(azure ad sp create $azure_client_id --json | jq -r .objectId) fi if [ $? -ne 0 ]; then