@@ -112,8 +112,15 @@ steps:
112112 #[[ -n $SYSTEM_DEBUG ]] && [[ $SYSTEM_DEBUG =~ $IS_TRUE ]] && set -x || set +x
113113 az upgrade -y
114114
115- echo "az storage account create --name "$STORAGEACCOUNT_NAME" --location "$STORAGEACCOUNT_LOCATION" --resource-group "$RESOURCEGROUP_NAME" --allow-blob-public-access false --allow-shared-key-access false --tags "$BUILDTAG_DEFINITIONID"="$SYSTEM_DEFINITIONID" "$BUILDTAG_CREATEDBYBUILDID"="$BUILD_BUILDID" "$BUILDTAG_CREATEDBYAPPID"="$servicePrincipalId""
116- az storage account create --name "$STORAGEACCOUNT_NAME" --location "$STORAGEACCOUNT_LOCATION" --resource-group "$RESOURCEGROUP_NAME" --allow-blob-public-access false --allow-shared-key-access false --tags "$BUILDTAG_DEFINITIONID"="$SYSTEM_DEFINITIONID" "$BUILDTAG_CREATEDBYBUILDID"="$BUILD_BUILDID" "$BUILDTAG_CREATEDBYAPPID"="$servicePrincipalId"
115+ az storage account create \
116+ --name "$STORAGEACCOUNT_NAME" \
117+ --location "$STORAGEACCOUNT_LOCATION" \
118+ --resource-group "$RESOURCEGROUP_NAME" \
119+ --allow-blob-public-access false \
120+ --allow-shared-key-access false \
121+ --tags "$BUILDTAG_DEFINITIONID"="$SYSTEM_DEFINITIONID" \
122+ "$BUILDTAG_CREATEDBYBUILDID"="$BUILD_BUILDID" \
123+ "$BUILDTAG_CREATEDBYAPPID"="$servicePrincipalId"
117124
118125 ${{ elseif eq(parameters.resourceType, 'roledefinition') }} :
119126 inlineScript : |
@@ -134,30 +141,6 @@ steps:
134141 --tags "$ACNCI_BUILDTAG_DEFINITIONID"="$SYSTEM_DEFINITIONID" \
135142 "$ACNCI_BUILDTAG_CREATEDBYBUILDID"="$BUILD_BUILDID" \
136143 "$ACNCI_BUILDTAG_CREATEDBYAPPID"="$servicePrincipalId"
137-
138- ${{ elseif eq(parameters.resourceType, 'serviceconnection') }} :
139- inlineScript : |
140- set -e
141- [[ -n $SYSTEM_DEBUG ]] && [[ $SYSTEM_DEBUG =~ $IS_TRUE ]] && set -x || set +x
142-
143- ## Requires manual creation
144-
145- #az config set extension.use_dynamic_install=yes_without_prompt
146- ##az devops login --identity "$SERVICECONNECTION_PRINCIPALID"
147- #az config set extension.dynamic_install_allow_preview=true
148- ##jq '.requiredResourceAccess = "$STORAGECONTAINER_ID"'
149- ##jq '.appId = "$MANAGEDIDENTITY_APPID"'
150- ##jq '.tags["$BUILDTAG_APPID"] = "$APPID"'
151- ##jq '.tags["$BUILDTAG_DEFINITIONID"] = "$SYSTEM_DEFINITIONID"'
152- #az devops login
153- #az devops service-endpoint azurerm create \
154- #--org "https://dev.azure.com/msazure/" \
155- #--azure-rm-service-principal-id "$SERVICECONNECTION_PRINCIPALID" \
156- #--azure-rm-subscription-id "$SUBSCRIPTION_ID" \
157- #--azure-rm-subscription-name "$SUBSCRIPTION_NAME" \
158- #--azure-rm-tenant-id "$SERVICECONNECTION_TENANT_ID"\
159- #--name "$SERVICECONNECTION_NAME" \
160- #--project "One" --debug
161144
162145
163146
@@ -222,6 +205,14 @@ steps:
222205 set -e
223206 [[ -n $SYSTEM_DEBUG ]] && [[ $SYSTEM_DEBUG =~ $IS_TRUE ]] && set -x || set +x
224207
208+ echo "$ROLEASSIGNMENTS_LIST" | \
209+ jq -rc \
210+ --arg RA_NAME "$RA_NAME" \
211+ --arg RA_PRINCIPAL_ID "$RA_PRINCIPAL_ID" \
212+ --arg RA_SCOPE "$RA_SCOPE" \
213+ '. | select(.roleDefinitionName == $RA_NAME && .principalId == $RA_PRINCIPAL_ID && .scope == $RA_SCOPE)'
214+
215+
225216 ${{ elseif eq(parameters.resourceType, 'storageaccounts') }} :
226217 inlineScript : |
227218 set -e
@@ -240,7 +231,8 @@ steps:
240231 CONDITION="(@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:Name] stringEquals '$STORAGECONTAINER_NAME' AND (!(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read'} AND NOT SubOperationMatches{'Blob.List'}) OR @Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs/tags:'$BUILDTAG_BUILDUSER_APPID'<\$key_case_sensitive\$>] StringEquals '$MANAGEDIDENTITY_APPID'))"
241232 az role assignment update \
242233 --role "$ROLE_NAME" \
243- --assignee "$MANAGEDIDENTITY_NAME" \
234+ --assignee-object-id "$SERVICEPRINCIPAL_CLIENTID" \
235+ --assignee-principl-type "ServicePrincipal" \
244236 --scope "$RESOURCEGROUP_ID" \
245237 --description "Enable access to build user blobs." \
246238 --condition "$CONDITION" \
0 commit comments