Skip to content

Commit 03532b5

Browse files
committed
update the scripts
1 parent dad3f37 commit 03532b5

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

articles/azure-resource-manager/templates/deployment-tutorial-linked-template.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ The following template is the main template. The highlighted **Microsoft.Resour
3030

3131
:::code language="json" source="~/resourcemanager-templates/get-started-deployment/linked-template/azuredeploy.json" highlight="27-32,40-58":::
3232

33-
Save a copy of the main template to your local computer.
33+
Save a copy of the main template to your local computer with the .json extension, for example, azuredeploy.json. You don't need to save a copy of the linked template. The linked template will be copied from a GitHub repository to a storage account.
3434

3535
## Store the linked template
3636

37-
The following PowerShell script creates a storage account, creates a container, copies the linked template from a github repository to the container. \
37+
The following PowerShell script creates a storage account, creates a container, and copies the linked template from a github repository to the container. A copy of the linked template is stored in [GitHub](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/get-started-deployment/linked-template/linkedStorageAccount.json).
3838

3939
Select **Try-it** to open the Cloud shell, select **Copy** to copy the PowerShell script, and right-click the shell pane to paste the script:
4040

@@ -74,19 +74,14 @@ Set-AzStorageBlobContent `
7474
-Blob $fileName `
7575
-Context $context
7676
77-
# List the template
78-
Get-AzStorageBlob `
79-
-Container $containerName `
80-
-Blob $fileName
81-
8277
Write-Host "Press [ENTER] to continue ..."
8378
```
8479

8580
## Deploy template
8681

8782
To deploy a private template in a storage account, generate a SAS token and include it in the URI for the template. Set the expiry time to allow enough time to complete the deployment. The blob containing the template is accessible to only the account owner. However, when you create a SAS token for the blob, the blob is accessible to anyone with that URI. If another user intercepts the URI, that user is able to access the template. A SAS token is a good way of limiting access to your templates, but you should not include sensitive data like passwords directly in the template.
8883

89-
If you haven't created the resource group, see [Create resource group](deployment-tutorial-linked-template.md#create-resource-group).
84+
If you haven't created the resource group, see [Create resource group](./deployment-tutorial-local-template.md#create-resource-group).
9085

9186
# [PowerShell](#tab/azure-powershell)
9287

@@ -95,8 +90,8 @@ If you haven't created the resource group, see [Create resource group](deploymen
9590
$projectName = Read-Host -Prompt "Enter a project name:" # This name is used to generate names for Azure resources, such as storage account name.
9691
$templateFile = Read-Host -Prompt "Enter the main template file and path"
9792
98-
$resourceGroupName = $projectName + "rg"
99-
$storageAccountName = $projectName + "store"
93+
$resourceGroupName="${projectName}rg"
94+
$storageAccountName="${projectName}store"
10095
$containerName = "templates"
10196
$fileName = "linkedStorageAccount.json" # A file name used for downloading and uploading the linked template.
10297
@@ -116,7 +111,7 @@ $linkedTemplateUri = New-AzStorageBlobSASToken `
116111
New-AzResourceGroupDeployment `
117112
-Name DeployLinkedTemplate `
118113
-ResourceGroupName $resourceGroupName `
119-
-TemplateUri $templateUri `
114+
-TemplateFile $templateFile `
120115
-projectName $projectName `
121116
-linkedTemplateUri $linkedTemplateUri `
122117
-verbose
@@ -135,7 +130,7 @@ read templateFile
135130
136131
resourceGroupName="${projectName}rg"
137132
storageAccountName="${projectName}store"
138-
containerName = "templates"
133+
containerName="templates"
139134
fileName="linkedStorageAccount.json"
140135
141136
key=$(az storage account keys list -g $resourceGroupName -n $storageAccountName --query [0].value -o tsv)
@@ -149,11 +144,11 @@ linkedTemplateUri=$(az storage blob generate-sas \
149144
--expiry `date -u -d "120 minutes" '+%Y-%m-%dT%H:%MZ'` \
150145
--full-uri)
151146
152-
147+
linkedTemplateUri=$(echo $linkedTemplateUri | sed 's/"//g')
153148
az deployment group create \
154149
--name DeployLinkedTemplate \
155-
--resource-group myResourceGroup \
156-
--template-uri $templateFile \
150+
--resource-group $resourceGroupName \
151+
--template-file $templateFile \
157152
--parameters projectName=$projectName linkedTemplateUri=$linkedTemplateUri \
158153
--verbose
159154
```
@@ -162,9 +157,7 @@ az deployment group create \
162157

163158
## Clean up resources
164159

165-
If you're moving on to the next tutorial, you don't need to delete the resource groups.
166-
167-
If you're stopping now, you might want to clean up the resources you deployed by deleting the resource groups.
160+
Clean up the resources you deployed by deleting the resource group.
168161

169162
1. From the Azure portal, select **Resource group** from the left menu.
170163
2. Enter the resource group name in the **Filter by name** field.

articles/azure-resource-manager/templates/deployment-tutorial-local-template.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ The template deploys a storage account, app service plan, and web app.
3838

3939
:::code language="json" source="~/resourcemanager-templates/get-started-deployment/local-template/azuredeploy.json":::
4040

41-
Save a copy of the template to your local computer. You deploy this template later in the tutorial.
41+
> [!IMPORTANT]
42+
> Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. The name must be unique. In the template, the storage account name is the project name with "store" appended, and the project name must be between 3 and 11 characters. So the project name must meet the storage account name requirements and has less than 11 characters.
43+
44+
Save a copy of the template to your local computer with the .json extension, for example, azuredeploy.json. You deploy this template later in the tutorial.
4245

4346
## Sign in to Azure
4447

@@ -56,6 +59,20 @@ Connect-AzAccount
5659
az login
5760
```
5861

62+
If you have multiple Azure subscriptions, select the subscription you want to use:
63+
64+
# [PowerShell](#tab/azure-powershell)
65+
66+
```azurepowershell
67+
Select-AzSubscription [SubscriptionID/SubscriptionName]
68+
```
69+
70+
# [Azure CLI](#tab/azure-cli)
71+
72+
```azurecli
73+
az account set --subscription [SubscriptionID/SubscriptionName]
74+
```
75+
5976
---
6077

6178
## Create resource group
@@ -121,7 +138,7 @@ az deployment group create \
121138
--name DeployLocalTemplate \
122139
--resource-group $resourceGroupName \
123140
--template-file $templateFile \
124-
--parameters projectname=$projectName \
141+
--parameters projectName=$projectName \
125142
--verbose
126143
```
127144

@@ -131,9 +148,7 @@ To learn more about deploying template by using Azure CLI, see [Deploy resources
131148

132149
## Clean up resources
133150

134-
If you're moving on to the next tutorial, you don't need to delete the resource group.
135-
136-
If you're stopping now, you might want to clean up the resources you deployed by deleting the resource group.
151+
Clean up the resources you deployed by deleting the resource group.
137152

138153
1. From the Azure portal, select **Resource group** from the left menu.
139154
2. Enter the resource group name in the **Filter by name** field.

0 commit comments

Comments
 (0)