1+ parameters :
2+ - name : requireBlobService
3+ type : bool
4+ default : false
15
26steps :
37
@@ -128,6 +132,17 @@ steps:
128132 env :
129133 INFRA_RG_LIST : $(INFRA_RG_LIST)
130134 INFRA_RG_LENGTH : $(INFRA_RG_LENGTH)
135+
136+ - task : AzureCLI@2
137+ displayName : " [Check] "
138+ inputs :
139+ azureSubscription : $(ACN_TEST_SERVICE_CONNECTION)
140+ scriptType : bash
141+ scriptLocation : inlineScript
142+ addSpnToEnvironment : true
143+ inlineScript : |
144+ set -e
145+ [[ -n $SYSTEM_DEBUG ]] && [[ $SYSTEM_DEBUG =~ $IS_TRUE ]] && set -x || set +x
131146
132147# # Managed Identity ##
133148# Inherited Env Vars:
@@ -329,28 +344,6 @@ steps:
329344 ACNCI_BUILDUSER_ROLE_NAME : $(ACNCI_BUILDUSER_ROLE_NAME)
330345
331346
332- # - task: AzureCLI@2
333- # inputs:
334- # azureSubscription: $(ACN_TEST_SERVICE_CONNECTION)
335- # scriptType: bash
336- # scriptLocation: inlineScript
337- # addSpnToEnvironment: true
338- # inlineScript: |
339- # set -e
340- # [[ -n $SYSTEM_DEBUG ]] && [[ $SYSTEM_DEBUG =~ $IS_TRUE ]] && set -x || set +x
341- #
342- # STORAGE_ACC_ID=$(az storage account show \
343- # --resource-group "$ACNCI_BUILD_RESOURCEGROUP_ID" \
344- # --name "$STORAGE_ACC" \
345- # --query id -o tsv)
346- # USER_ASSIGNED_CLIENT_ID=$(az identity show --resource-group "$RG" --name "$USER_ASSIGNED_IDENTITY_NAME" --query 'clientId' -o tsv)
347- # az role assignment create \
348- # --role "Storage Blob Data Contributor" \
349- # --assignee "$USER_ASSIGNED_CLIENT_ID" \
350- # --scope "$STORAGE_ACC_ID"
351- # env:
352- # ACNCI_BUILD_RESOURCEGROUP_ID: $(resourcegroups.ACNCI_BUILD_RESOURCEGROUP_ID)
353-
354347- template : get-storage-accounts.steps.yaml
355348 parameters :
356349 STORAGE_ACCOUNT_SERVICE_CONNECTION : $(ACN_TEST_SERVICE_CONNECTION)
@@ -471,6 +464,29 @@ steps:
471464 SA_LIST_LENGTH : $(SA_LIST_LENGTH)
472465 SA_SERVICE_CONN : $(ACN_TEST_SERVICE_CONNECTION)
473466
467+ - task : AzureCLI@2
468+ displayName : " [Provision] Container Access Permissions"
469+ continueOnError : true
470+ condition : and(succeeded(), parameters.requireBlobService)
471+ inputs :
472+ azureSubscription : $(ACN_TEST_SERVICE_CONNECTION)
473+ scriptType : bash
474+ scriptLocation : inlineScript
475+ addSpnToEnvironment : true
476+ inlineScript : |
477+ set -e
478+ [[ -n $SYSTEM_DEBUG ]] && [[ $SYSTEM_DEBUG =~ $IS_TRUE ]] && set -x || set +x
479+
480+ az role assignment create \
481+ --role "Storage Blob Data Contributor" \
482+ --assignee "$ACNCI_MANAGEDIDENTITY_OBJECTID" \
483+ --assignee-principal-type "ServicePrincipal" \
484+ --scope "$ACNCI_STORAGEACCOUNT_ID"
485+ env :
486+ ACNCI_BUILD_RESOURCEGROUP_ID : $(resourcegroups.ACNCI_BUILD_RESOURCEGROUP_ID)
487+ ACNCI_MANAGEDIDENTITY_OBJECTID : $(managedidentity.ACNCI_MANAGEDIDENTITY_OBJECTID)
488+ ACNCI_STORAGEACCOUNT_ID : $(storageaccounts.ACNCI_STORAGEACCOUNT_ID)
489+
474490# - task: AzureCLI@2
475491# displayName: "[Grant] Storage Account Access Permissions"
476492# inputs:
@@ -504,6 +520,7 @@ steps:
504520 set -e
505521 [[ -n $SYSTEM_DEBUG ]] && [[ $SYSTEM_DEBUG =~ $IS_TRUE ]] && set -x || set +x
506522
523+ az login --identity "$ACNCI_MANAGEDIDENTITY_ID"
507524 az storage account show -n "$SA_NAME" --query networkRuleSet
508525 az storage container create \
509526 --account-name "$SA_NAME" \
@@ -517,6 +534,7 @@ steps:
517534 CONTAINER_NAME : " azure-container-networking-pr"
518535 RG_NAME : $(resourcegroups.ACNCI_BUILD_RESOURCEGROUP)
519536 SA_NAME : $(artifact_storage.ACNCI_STORAGEACCOUNT_NAME)
537+ ACNCI_MANAGEDIDENTITY_ID : $(managedidentity.ACNCI_MANAGEDIDENTITY_ID)
520538
521539- task : AzureCLI@2
522540 name : artifact_blob
0 commit comments