PageRenderTime 70ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

/articles/virtual-network/virtual-network-deploy-static-pip-arm-template.md

https://gitlab.com/yeah568/azure-content
Markdown | 185 lines | 144 code | 41 blank | 0 comment | 0 complexity | 413fb09739e4304d014de533d39239ad MD5 | raw file
  1. <properties
  2. pageTitle="Deploy a VM with a static public IP using a template in Resource Manager | Microsoft Azure"
  3. description="Learn how to deploy VMs with a static public IP using a template in Resource Manager"
  4. services="virtual-network"
  5. documentationCenter="na"
  6. authors="telmosampaio"
  7. manager="carmonm"
  8. editor=""
  9. tags="azure-resource-manager"
  10. />
  11. <tags
  12. ms.service="virtual-network"
  13. ms.devlang="na"
  14. ms.topic="article"
  15. ms.tgt_pltfrm="na"
  16. ms.workload="infrastructure-services"
  17. ms.date="04/27/2016"
  18. ms.author="telmos" />
  19. # Deploy a VM with a static public IP using a template
  20. [AZURE.INCLUDE [virtual-network-deploy-static-pip-arm-selectors-include.md](../../includes/virtual-network-deploy-static-pip-arm-selectors-include.md)]
  21. [AZURE.INCLUDE [virtual-network-deploy-static-pip-intro-include.md](../../includes/virtual-network-deploy-static-pip-intro-include.md)]
  22. [AZURE.INCLUDE [azure-arm-classic-important-include](../../includes/learn-about-deployment-models-rm-include.md)] classic deployment model.
  23. [AZURE.INCLUDE [virtual-network-deploy-static-pip-scenario-include.md](../../includes/virtual-network-deploy-static-pip-scenario-include.md)]
  24. ## Public IP resources in a template file
  25. You can view and download the [sample template](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/IaaS-Story/03-Static-public-IP/azuredeploy.json).
  26. The section below shows the definition of the public IP resource, based on the scenario above.
  27. {
  28. "apiVersion": "2015-06-15",
  29. "type": "Microsoft.Network/publicIPAddresses",
  30. "name": "[variables('webVMSetting').pipName]",
  31. "location": "[variables('location')]",
  32. "properties": {
  33. "publicIPAllocationMethod": "Static"
  34. },
  35. "tags": {
  36. "displayName": "PublicIPAddress - Web"
  37. }
  38. },
  39. Notice the **publicIPAllocationMethod** property, which is set to *Static*. This property can be either *Dynamic* (default value) or *Static*. Setting it to static guarantees that the public IP address assigned will never change.
  40. The section below shows the association of the public IP address with a network interface.
  41. {
  42. "apiVersion": "2015-06-15",
  43. "type": "Microsoft.Network/networkInterfaces",
  44. "name": "[variables('webVMSetting').nicName]",
  45. "location": "[variables('location')]",
  46. "tags": {
  47. "displayName": "NetworkInterface - Web"
  48. },
  49. "dependsOn": [
  50. "[concat('Microsoft.Network/publicIPAddresses/', variables('webVMSetting').pipName)]",
  51. "[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]"
  52. ],
  53. "properties": {
  54. "ipConfigurations": [
  55. {
  56. "name": "ipconfig1",
  57. "properties": {
  58. "privateIPAllocationMethod": "Static",
  59. "privateIPAddress": "[variables('webVMSetting').ipAddress]",
  60. "publicIPAddress": {
  61. "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('webVMSetting').pipName)]"
  62. },
  63. "subnet": {
  64. "id": "[variables('frontEndSubnetRef')]"
  65. }
  66. }
  67. }
  68. ]
  69. }
  70. },
  71. Notice the **publicIPAddress** property pointing to the **Id** of a resource named **variables('webVMSetting').pipName**. That is the name of the public IP resource shown above.
  72. Finally, the network interface above is listed in the **networkProfile** property of the VM being created.
  73. "networkProfile": {
  74. "networkInterfaces": [
  75. {
  76. "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('webVMSetting').nicName)]"
  77. }
  78. ]
  79. }
  80. ## Deploy the template by using click to deploy
  81. The sample template available in the public repository uses a parameter file containing the default values used to generate the scenario described above. To deploy this template using click to deploy, click **Deploy to Azure** in the Readme.md file for the [VM with static PIP](https://github.com/Azure/azure-quickstart-templates/tree/master/IaaS-Story/03-Static-public-IP) template. Replace the default parameter values if desired and enter values for the blank parameters. Follow the instructions in the portal to create a virtual machine with a static public IP address.
  82. ## Deploy the template by using PowerShell
  83. To deploy the template you downloaded by using PowerShell, follow the steps below.
  84. 1. If you have never used Azure PowerShell, see [How to Install and Configure Azure PowerShell](../powershell-install-configure.md) and follow the instructions in steps 1 to 3.
  85. 2. In a PowerShell console, run the **New-AzureRmResourceGroup** cmdlet to create a new resource group, if necessary. If you already have a resource group created, go to step 3.
  86. New-AzureRmResourceGroup -Name PIPTEST -Location westus
  87. Expected output:
  88. ResourceGroupName : PIPTEST
  89. Location : westus
  90. ProvisioningState : Succeeded
  91. Tags :
  92. ResourceId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/StaticPublicIP
  93. 3. In a PowerShell console, run the **New-AzureRmResourceGroupDeployment** cmdlet to deploy the template.
  94. New-AzureRmResourceGroupDeployment -Name DeployVM -ResourceGroupName PIPTEST `
  95. -TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/IaaS-Story/03-Static-public-IP/azuredeploy.json `
  96. -TemplateParameterUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/IaaS-Story/03-Static-public-IP/azuredeploy.parameters.json
  97. Expected output:
  98. DeploymentName : DeployVM
  99. ResourceGroupName : PIPTEST
  100. ProvisioningState : Succeeded
  101. Timestamp : <Deployment date> <Deployment time>
  102. Mode : Incremental
  103. TemplateLink :
  104. Uri : https://raw.githubusercontent.com/Azure/azure-quickstart-templates/mas
  105. ter/IaaS-Story/03-Static-public-IP/azuredeploy.json
  106. ContentVersion : 1.0.0.0
  107. Parameters :
  108. Name Type Value
  109. ======================== ========================= ==========
  110. vnetName String WTestVNet
  111. vnetPrefix String 192.168.0.0/16
  112. frontEndSubnetName String FrontEnd
  113. frontEndSubnetPrefix String 192.168.1.0/24
  114. storageAccountNamePrefix String iaasestd
  115. stdStorageType String Standard_LRS
  116. osType String Windows
  117. adminUsername String adminUser
  118. adminPassword SecureString
  119. Outputs :
  120. ## Deploy the template by using the Azure CLI
  121. To deploy the template by using the Azure CLI, follow the steps below.
  122. 1. If you have never used Azure CLI, follow the steps in the [Install and Configure the Azure CLI](../xplat-cli-install.md) article and then the steps to connect the CLI to your subscription in the "Use azure login to authenticate interactively" section of the [Connect to an Azure subscription from the Azure Command-Line Interface (Azure CLI)](../xplat-cli-connect.md) article.
  123. 2. Run the **azure config mode** command to switch to Resource Manager mode, as shown below.
  124. azure config mode arm
  125. Here is the expected output for the command above:
  126. info: New mode is arm
  127. 3. Open the [parameter file](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/IaaS-Story/03-Static-public-IP/azuredeploy.parameters.json), select its content, and save it to a file in your computer. For this example, the parameters are saved to a file named *parameters.json*. Change the parameter values within the file if desired, but at a minimum, it's recommended that you change the value for the adminPassword parameter to a unique, complex password.
  128. 4. Run the **azure group deployment create** cmdlet to deploy the new VNet by using the template and parameter files you downloaded and modified above. In the command below, replace <path> with the path you saved the file to.
  129. azure group create -n PIPTEST2 -l westus --template-uri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/IaaS-Story/03-Static-public-IP/azuredeploy.json -e <path>\parameters.json
  130. Expected output (lists parameter values used):
  131. info: Executing command group create
  132. + Getting resource group PIPTEST2
  133. + Creating resource group PIPTEST2
  134. info: Created resource group PIPTEST2
  135. + Initializing template configurations and parameters
  136. + Creating a deployment
  137. info: Created template deployment "azuredeploy"
  138. data: Id: /subscriptions/<Subscription ID>/resourceGroups/PIPTEST2
  139. data: Name: PIPTEST2
  140. data: Location: westus
  141. data: Provisioning State: Succeeded
  142. data: Tags: null
  143. data:
  144. info: group create command OK