Skip to content

Commit c01c471

Browse files
committed
more work
1 parent 9de5be9 commit c01c471

File tree

1 file changed

+27
-73
lines changed

1 file changed

+27
-73
lines changed

articles/virtual-network/ip-services/create-public-ip-terraform.md

Lines changed: 27 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ In this article, you learn how to:
3333
> * Create a standard static public IPv4 address named **myRoutingPreferenceStandardPublicIP** that supports the Routing Preference feature
3434
> * Create a standard static public IPv4 address named **myGlobalTierStandardPublicIP** that supports the Global Tier feature
3535
36+
> [!NOTE]
37+
> The sample code for this article is located in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-virtual-network-public-ip). You can view the log file containing the [test results from current and previous versions of Terraform](https://github.com/Azure/terraform/tree/master/quickstart/101-virtual-network-public-ip/TestRecord.md).
38+
>
39+
> See more [articles and sample code showing how to use Terraform to manage Azure resources](/azure/terraform)
40+
3641
## Create a resource group
3742

3843
An Azure resource group is a logical container into which Azure resources are deployed and managed.
@@ -46,20 +51,10 @@ An Azure resource group is a logical container into which Azure resources are de
4651
>[!NOTE]
4752
>Standard SKU public IP is recommended for production workloads. For more information about SKUs, see **[Public IP addresses](public-ip-addresses.md)**.
4853
>
49-
>The following command works for API version **2020-08-01** or **later**. For more information about the API version currently being used, see [Resource Providers and Types](../../azure-resource-manager/management/resource-providers-and-types.md).
50-
51-
Use [az network public-ip create](/cli/azure/network/public-ip#az-network-public-ip-create) to create a standard zone-redundant public IPv4 address named **myStandardPublicIP** in **QuickStartCreateIP-rg**.
54+
>The following command snippet works for API version **2020-08-01** or **later**. For more information about the API version currently being used, see [Resource Providers and Types](../../azure-resource-manager/management/resource-providers-and-types.md).
5255
53-
To create an IPv6 address, modify the `--version` parameter to **IPv6**.
56+
:::code language="terraform" source="~/terraform_samples/quickstart/101-virtual-network-public-ip/main.tf" range="10-18":::
5457

55-
```azurecli-interactive
56-
az network public-ip create \
57-
--resource-group QuickStartCreateIP-rg \
58-
--name myStandardPublicIP \
59-
--version IPv4 \
60-
--sku Standard \
61-
--zone 1 2 3
62-
```
6358
> [!IMPORTANT]
6459
> For versions of the API older than 2020-08-01, execute the command without specifying a `--zone` parameter to create a zone-redundant IP address.
6560
>
@@ -68,19 +63,11 @@ To create an IPv6 address, modify the `--version` parameter to **IPv6**.
6863

6964
In this section, you create a basic IP. Basic public IPs don't support availability zones.
7065

71-
Use [az network public-ip create](/cli/azure/network/public-ip#az-network-public-ip-create) to create a basic static public IPv4 address named **myBasicPublicIP** in **QuickStartCreateIP-rg**.
66+
The followingcode snippet creates an IPv6 address, modify the `--version` parameter to **IPv6**.
7267

73-
To create an IPv6 address, modify the `--version` parameter to **IPv6**.
68+
:::code language="terraform" source="~/terraform_samples/quickstart/101-virtual-network-public-ip/main.tf" range="20-27":::
7469

75-
```azurecli-interactive
76-
az network public-ip create \
77-
--resource-group QuickStartCreateIP-rg \
78-
--name myBasicPublicIP \
79-
--version IPv4 \
80-
--sku Basic \
81-
--allocation-method Static
82-
```
83-
If it's acceptable for the IP address to change over time, **Dynamic** IP assignment can be selected by changing the **`--allocation-method`** to **Dynamic**.
70+
If it's acceptable for the IP address to change over time, **Dynamic** IP assignment can be selected by changing the `allocation_method` value to **Dynamic**.
8471

8572
>[!NOTE]
8673
> A basic IPv6 address must always be `Dynamic`.
@@ -93,18 +80,11 @@ In this section, you learn how to create a zonal or no-zone public IP address.
9380

9481
# [**Zonal**](#tab/create-public-ip-zonal)
9582

96-
To create a standard zonal public IPv4 address in Zone 2 named **myStandardPublicIP** in **QuickStartCreateIP-rg**, use the following command.
83+
The following code snippet creates a standard zonal public IPv4 address in Zone 2 named **myZonalStandardPublicIP**.
9784

98-
To create an IPv6 address, modify the `--version` parameter to **IPv6**.
85+
To create an IPv6 address, set the `version` value to **IPv6**.
9986

100-
```azurecli-interactive
101-
az network public-ip create \
102-
--resource-group QuickStartCreateIP-rg \
103-
--name myStandardPublicIP-zonal \
104-
--version IPv4 \
105-
--sku Standard \
106-
--zone 2
107-
```
87+
:::code language="terraform" source="~/terraform_samples/quickstart/101-virtual-network-public-ip/main.tf" range="29-37":::
10888

10989
>[!NOTE]
11090
>The above options for zones are only valid selections in regions with [Availability Zones](../../reliability/availability-zones-overview.md?toc=%2fazure%2fvirtual-network%2ftoc.json).
@@ -116,20 +96,15 @@ In this section, you create a non-zonal IP address.
11696
>[!NOTE]
11797
>The following command works for API version 2020-08-01 or later. For more information about the API version currently being used, see [Resource Providers and Types](../../azure-resource-manager/management/resource-providers-and-types.md).
11898
119-
Use [az network public-ip create](/cli/azure/network/public-ip#az-network-public-ip-create) to create a standard public IPv4 address as a non-zonal resource named **myStandardPublicIP-nozone** in **QuickStartCreateIP-rg**.
99+
The following code snippet creates a standard public IPv4 address as a non-zonal resource named **myNonZonalStandardPublicIP**.
120100

121-
To create an IPv6 address, modify the `--version` parameter to **IPv6**.
101+
To create an IPv6 address, set the `version` value to **IPv6**.
122102

123-
```azurecli-interactive
124-
az network public-ip create \
125-
--resource-group QuickStartCreateIP-rg \
126-
--name myStandardPublicIP-nozone \
127-
--version IPv4 \
128-
--sku Standard
129-
```
130-
The removal of the `--zone` parameter in the command is valid in all regions.
103+
:::code language="terraform" source="~/terraform_samples/quickstart/101-virtual-network-public-ip/main.tf" range="39-46":::
131104

132-
The removal of the `--zone` parameter is the default selection for standard public IP addresses in regions without [Availability Zones](../../reliability/availability-zones-overview.md?toc=%2fazure%2fvirtual-network%2ftoc.json).
105+
The removal of the `zone` field is valid in all regions.
106+
107+
The removal of the `zone` field is the default selection for standard public IP addresses in regions without [Availability Zones](../../reliability/availability-zones-overview.md?toc=%2fazure%2fvirtual-network%2ftoc.json).
133108

134109
---
135110

@@ -145,55 +120,34 @@ The selection of **Internet** minimizes travel on Microsoft's network, instead u
145120

146121
For more information on routing preference, see [What is routing preference (preview)?](routing-preference-overview.md).
147122

148-
The command creates a new standard zone-redundant public IPv4 address with a routing preference of type **Internet**:
123+
The following code snippet creates a new standard zone-redundant public IPv4 address with a routing preference of type **Internet**:
149124

150-
```azurecli-interactive
151-
az network public-ip create \
152-
--resource-group QuickStartCreateIP-rg \
153-
--name myStandardPublicIP-RP \
154-
--version IPv4 \
155-
--ip-tags 'RoutingPreference=Internet' \
156-
--sku Standard \
157-
--zone 1 2 3
158-
```
125+
:::code language="terraform" source="~/terraform_samples/quickstart/101-virtual-network-public-ip/main.tf" range="48-61":::
159126

160127
# [**Tier**](#tab/tier)
161128

162129
Public IP addresses are associated with a single region. The **Global** tier spans an IP address across multiple regions. **Global** tier is required for the frontends of cross-region load balancers.
163130

164131
For more information, see [Cross-region load balancer](../../load-balancer/cross-region-overview.md).
165132

166-
The following command creates a global IPv4 address. This address can be associated with the frontend of a cross-region load balancer.
133+
The following code snippet creates a global IPv4 address. This address can be associated with the frontend of a cross-region load balancer.
134+
135+
:::code language="terraform" source="~/terraform_samples/quickstart/101-virtual-network-public-ip/main.tf" range="63-71":::
167136

168-
```azurecli-interactive
169-
az network public-ip create \
170-
--resource-group QuickStartCreateIP-rg \
171-
--name myStandardPublicIP-Global \
172-
--version IPv4 \
173-
--tier global \
174-
--sku Standard
175-
```
176137
>[!NOTE]
177138
>Global tier addresses don't support Availability Zones.
178139
179140
---
180141

181142
## Clean up resources
182143

183-
If you're not going to continue to use this application, delete the public IP address with the following steps:
184-
185-
1. In the search box at the top of the portal, enter **Resource group**.
186-
187-
2. In the search results, select **Resource groups**.
188-
189-
3. Select **QuickStartCreateIP-rg**.
144+
[!INCLUDE [terraform-plan-destroy.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan-destroy.md)]
190145

191-
4. Select **Delete resource group**.
146+
## Troubleshoot Terraform on Azure
192147

193-
5. Enter **QuickStartCreateIP-rg** for **TYPE THE RESOURCE GROUP NAME** and select **Delete**.
148+
[Troubleshoot common problems when using Terraform on Azure](/azure/developer/terraform/troubleshoot)
194149

195150
## Next steps
196151

197-
Advance to the next article to learn how to create a public IP prefix:
198152
> [!div class="nextstepaction"]
199153
> [Create public IP prefix using the Azure CLI](create-public-ip-prefix-cli.md)

0 commit comments

Comments
 (0)