|
9 | 9 | RAND=$(openssl rand -hex 4) |
10 | 10 | SA1="sa1${RAND}" |
11 | 11 | SA2="sa2${RAND}" |
12 | | -API_VER="2025-06-01" |
| 12 | + |
| 13 | +# Set subscription context |
| 14 | +az account set --subscription "$SUBSCRIPTION_ID" |
13 | 15 |
|
14 | 16 | # Create storage accounts |
15 | 17 | for SA in "$SA1" "$SA2"; do |
16 | 18 | echo "==> Creating storage account $SA" |
17 | | - az rest --method put \ |
18 | | - --url "https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RG/providers/Microsoft.Storage/storageAccounts/$SA?api-version=$API_VER" \ |
19 | | - --body "{ |
20 | | - \"location\": \"$LOCATION\", |
21 | | - \"sku\": { \"name\": \"Standard_LRS\" }, |
22 | | - \"kind\": \"StorageV2\", |
23 | | - \"properties\": { |
24 | | - \"minimumTlsVersion\": \"TLS1_2\", |
25 | | - \"allowBlobPublicAccess\": false, |
26 | | - \"allowSharedKeyAccess\": false |
27 | | - } |
28 | | - }" \ |
| 19 | + az storage account create \ |
| 20 | + --name "$SA" \ |
| 21 | + --resource-group "$RG" \ |
| 22 | + --location "$LOCATION" \ |
| 23 | + --sku Standard_LRS \ |
| 24 | + --kind StorageV2 \ |
| 25 | + --allow-blob-public-access false \ |
| 26 | + --https-only true \ |
| 27 | + --min-tls-version TLS1_2 \ |
| 28 | + --query "name" -o tsv \ |
29 | 29 | && echo "Storage account $SA created successfully." |
30 | 30 | done |
31 | 31 |
|
32 | 32 | echo "All storage accounts created successfully." |
| 33 | + |
| 34 | +# Set pipeline output variables |
33 | 35 | set +x |
34 | | - echo "##vso[task.setvariable variable=StorageAccount1;isOutput=true]$SA1" |
35 | | - echo "##vso[task.setvariable variable=StorageAccount2;isOutput=true]$SA2" |
| 36 | +echo "##vso[task.setvariable variable=StorageAccount1;isOutput=true]$SA1" |
| 37 | +echo "##vso[task.setvariable variable=StorageAccount2;isOutput=true]$SA2" |
36 | 38 | set -x |
0 commit comments