Skip to content

Commit a6377c5

Browse files
authored
Merge pull request #111703 from mumian/0416-vm
update the vm extension article
2 parents 2d5fa71 + 0003047 commit a6377c5

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

articles/azure-resource-manager/templates/template-tutorial-deploy-vm-extensions.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Deploy VM extensions with template
33
description: Learn how to deploy virtual machine extensions with Azure Resource Manager templates
44
author: mumian
5-
ms.date: 03/31/2020
5+
ms.date: 04/16/2020
66
ms.topic: tutorial
77
ms.author: jgao
88
---
@@ -18,7 +18,6 @@ This tutorial covers the following tasks:
1818
> * Open a quickstart template
1919
> * Edit the template
2020
> * Deploy the template
21-
> * Verify the deployment
2221
2322
If you don't have an Azure subscription, [create a free account](https://azure.microsoft.com/free/) before you begin.
2423

@@ -37,29 +36,34 @@ To complete this article, you need:
3736

3837
## Prepare a PowerShell script
3938

40-
A PowerShell script with the following content is shared from [GitHub](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/tutorial-vm-extension/installWebServer.ps1):
39+
You can use inline PowerShell script or a script file. This tutorial shows how to use a script file. A PowerShell script with the following content is shared from [GitHub](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/tutorial-vm-extension/installWebServer.ps1):
4140

4241
```azurepowershell
4342
Install-WindowsFeature -name Web-Server -IncludeManagementTools
4443
```
4544

46-
If you choose to publish the file to your own location, you must update the `fileUri` element in the template later in the tutorial.
45+
If you choose to publish the file to your own location, update the `fileUri` element in the template later in the tutorial.
4746

4847
## Open a quickstart template
4948

5049
Azure Quickstart Templates is a repository for ARM templates. Instead of creating a template from scratch, you can find a sample template and customize it. The template used in this tutorial is called [Deploy a simple Windows VM](https://azure.microsoft.com/resources/templates/101-vm-simple-windows/).
5150

5251
1. In Visual Studio Code, select **File** > **Open File**.
53-
1. In the **File name** box, paste the following URL: https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-simple-windows/azuredeploy.json
52+
1. In the **File name** box, paste the following URL:
53+
54+
```url
55+
https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-simple-windows/azuredeploy.json
56+
```
5457

5558
1. To open the file, select **Open**.
5659
The template defines five resources:
5760

58-
* **Microsoft.Storage/storageAccounts**. See the [template reference](https://docs.microsoft.com/azure/templates/Microsoft.Storage/storageAccounts).
59-
* **Microsoft.Network/publicIPAddresses**. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/publicipaddresses).
60-
* **Microsoft.Network/virtualNetworks**. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/virtualnetworks).
61-
* **Microsoft.Network/networkInterfaces**. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/networkinterfaces).
62-
* **Microsoft.Compute/virtualMachines**. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.compute/virtualmachines).
61+
* [**Microsoft.Storage/storageAccounts**](/azure/templates/Microsoft.Storage/storageAccounts).
62+
* [**Microsoft.Network/publicIPAddresses**](/azure/templates/microsoft.network/publicipaddresses).
63+
* [**Microsoft.Network/networkSecurityGroups**](/azure/templates/microsoft.network/networksecuritygroups).
64+
* [**Microsoft.Network/virtualNetworks**](/azure/templates/microsoft.network/virtualnetworks).
65+
* [**Microsoft.Network/networkInterfaces**](/azure/templates/microsoft.network/networkinterfaces).
66+
* [**Microsoft.Compute/virtualMachines**](/azure/templates/microsoft.compute/virtualmachines).
6367

6468
It's helpful to get some basic understanding of the template before you customize it.
6569
@@ -72,7 +76,7 @@ Add a virtual machine extension resource to the existing template with the follo
7276
```json
7377
{
7478
"type": "Microsoft.Compute/virtualMachines/extensions",
75-
"apiVersion": "2018-06-01",
79+
"apiVersion": "2019-12-01",
7680
"name": "[concat(variables('vmName'),'/', 'InstallWebServer')]",
7781
"location": "[parameters('location')]",
7882
"dependsOn": [
@@ -100,6 +104,14 @@ For more information about this resource definition, see the [extension referenc
100104
* **fileUris**: The locations where the script files are stored. If you choose not to use the provided location, you need to update the values.
101105
* **commandToExecute**: This command invokes the script.
102106

107+
To use inline script, remove **fileUris**, and update **commandToExecute** to:
108+
109+
```powershell
110+
powershell.exe Install-WindowsFeature -name Web-Server -IncludeManagementTools && powershell.exe remove-item 'C:\\inetpub\\wwwroot\\iisstart.htm' && powershell.exe Add-Content -Path 'C:\\inetpub\\wwwroot\\iisstart.htm' -Value $('Hello World from ' + $env:computername)
111+
```
112+
113+
This inline script also update the iisstart.html content.
114+
103115
You must also open the HTTP port so that you would be able to access the web server.
104116

105117
1. Find **securityRules** in the template.
@@ -125,11 +137,13 @@ You must also open the HTTP port so that you would be able to access the web ser
125137

126138
For the deployment procedure, see the "Deploy the template" section of [Tutorial: Create ARM templates with dependent resources](./template-tutorial-create-templates-with-dependent-resources.md#deploy-the-template). We recommended that you use a generated password for the virtual machine administrator account. See this article's [Prerequisites](#prerequisites) section.
127139

128-
## Verify the deployment
140+
From the Cloud Shell, run the following command to retrieve the public IP address of the VM:
141+
142+
```azurepowershell
143+
(Get-AzPublicIpAddress -ResourceGroupName $resourceGroupName).IpAddress
144+
```
129145

130-
1. In the Azure portal, select the VM.
131-
1. In the VM overview, copy the IP address by selecting **Click to copy**, and then paste it in a browser tab.
132-
The default Internet Information Services (IIS) welcome page opens:
146+
Paste the IP address into a Web browser. The default Internet Information Services (IIS) welcome page opens:
133147

134148
![The Internet Information Services welcome page](./media/template-tutorial-deploy-vm-extensions/resource-manager-template-deploy-extensions-customer-script-web-server.png)
135149

0 commit comments

Comments
 (0)