Skip to content

Commit 9938a11

Browse files
Merge pull request #234415 from TomArcherMsft/UserStory60501-notification-hub
User Story 60501: Notification Hubs
2 parents 9873c39 + f7aa910 commit 9938a11

File tree

3 files changed

+134
-13
lines changed

3 files changed

+134
-13
lines changed

articles/ddos-protection/manage-ddos-protection-terraform.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,6 @@ In this article, you learn how to:
113113
-Name $ddos_protection_plan_name
114114
```
115115

116-
1. Get the virtual network name.
117-
118-
```console
119-
$virtual_network_name=$(terraform output -raw virtual_network_name)
120-
```
121-
122-
1. Run [Get-AzVirtualNetwork](/powershell/module/az.network/get-azvirtualnetwork) to display information about the new virtual network.
123-
124-
```azurepowershell
125-
Get-AzVirtualNetwork -ResourceGroupName $resource_group_name `
126-
-Name $virtual_network_name
127-
```
128-
129116
---
130117

131118
## Clean up resources

articles/notification-hubs/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
- name: Create notification hub - Template
2020
displayName: Resource Manager
2121
href: create-notification-hub-template.md
22+
- name: Create notification hub - Terraform
23+
href: create-notification-hub-terraform.md
2224
- name: Configure a notification hub
2325
href: configure-notification-hub-portal-pns-settings.md
2426
- name: Tutorials
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
title: 'Quickstart: Create an Azure Notification Hub using Terraform'
3+
description: 'In this article, you create an Azure Notification Hub using Terraform'
4+
services: notification-hubs
5+
author: TomArcherMsft
6+
ms.topic: quickstart
7+
ms.custom: devx-track-terraform
8+
ms.service: notification-hubs
9+
ms.author: tarcher
10+
ms.date: 4/13/2023
11+
---
12+
13+
# Quickstart: Create an Azure Notification Hub using Terraform
14+
15+
This article uses Terraform to create an Azure Notification Hubs namespace and a notification hub. The name of each resource is randomly generated to avoid naming conflicts.
16+
17+
Azure Notification Hubs provides an easy-to-use and scaled-out push engine that enables you to send notifications to any platform (iOS, Android, Windows, Kindle, etc.) from any backend (cloud or on-premises). For more information about the service, see [What is Azure Notification Hubs](notification-hubs-push-notification-overview.md).
18+
19+
[!INCLUDE [Terraform abstract](~/azure-dev-docs-pr/articles/terraform/includes/abstract.md)]
20+
21+
In this article, you learn how to:
22+
23+
> [!div class="checklist"]
24+
> * Create a random value for the Azure resource group name using [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet).
25+
> * Create an Azure resource group using [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group).
26+
> * Create a random value for the Azure Notification Hub namespace name using [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string).
27+
> * Create an Azure Notification Hub namespace using [azurerm_notification_hub_namespace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/notification_hub_namespace).
28+
> * Create a random value for the Azure Notification Hub name using [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string).
29+
> * Create an Azure Notification Hub using [azurerm_notification_hub](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/notification_hub).
30+
31+
[!INCLUDE [AI attribution](../../includes/ai-generated-attribution.md)]
32+
33+
## Prerequisites
34+
35+
- [Install and configure Terraform](/azure/developer/terraform/quickstart-configure)
36+
37+
## Implement the Terraform code
38+
39+
> [!NOTE]
40+
> The sample code for this article is located in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-notification-hub). 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-notification-hub\TestRecord.md).
41+
>
42+
> See more [articles and sample code showing how to use Terraform to manage Azure resources](/azure/terraform)
43+
44+
1. Create a directory in which to test and run the sample Terraform code and make it the current directory.
45+
46+
1. Create a file named `providers.tf` and insert the following code:
47+
48+
[!code-terraform[master](~/terraform_samples/quickstart/101-notification-hub/providers.tf)]
49+
50+
1. Create a file named `main.tf` and insert the following code:
51+
52+
[!code-terraform[master](~/terraform_samples/quickstart/101-notification-hub/main.tf)]
53+
54+
1. Create a file named `variables.tf` and insert the following code:
55+
56+
[!code-terraform[master](~/terraform_samples/quickstart/101-notification-hub/variables.tf)]
57+
58+
1. Create a file named `outputs.tf` and insert the following code:
59+
60+
[!code-terraform[master](~/terraform_samples/quickstart/101-notification-hub/outputs.tf)]
61+
62+
## Initialize Terraform
63+
64+
[!INCLUDE [terraform-init.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-init.md)]
65+
66+
## Create a Terraform execution plan
67+
68+
[!INCLUDE [terraform-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan.md)]
69+
70+
## Apply a Terraform execution plan
71+
72+
[!INCLUDE [terraform-apply-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-apply-plan.md)]
73+
74+
## Verify the results
75+
76+
#### [Azure CLI](#tab/azure-cli)
77+
78+
1. Get the Azure resource group name.
79+
80+
```console
81+
resource_group_name=$(terraform output -raw resource_group_name)
82+
```
83+
84+
1. Get the namespace name.
85+
86+
```console
87+
notification_hub_namespace_name=$(terraform output -raw notification_hub_namespace_name)
88+
```
89+
90+
1. Run [az notification-hub list](/cli/azure/notification-hub#az-notification-hub-list) to display the hubs for the specified namespace.
91+
92+
```azurecli
93+
az notification-hub list \
94+
--resource-group $resource_group_name \
95+
--namespace-name $notification_hub_namespace_name
96+
```
97+
98+
#### [Azure PowerShell](#tab/azure-powershell)
99+
100+
1. Get the Azure resource group name.
101+
102+
```console
103+
$resource_group_name=$(terraform output -raw resource_group_name)
104+
```
105+
106+
1. Get the namespace name.
107+
108+
```console
109+
$notification_hub_namespace_name=$(terraform output -raw notification_hub_namespace_name)
110+
```
111+
112+
1. Run [Get-AzNotificationHub](/powershell/module/az.notificationhubs/get-aznotificationhub) to display the hubs for the specified namespace.
113+
114+
```azurepowershell
115+
Get-AzNotificationHub -ResourceGroup $resource_group_name `
116+
-Namespace $notification_hub_namespace_name
117+
```
118+
119+
---
120+
121+
## Clean up resources
122+
123+
[!INCLUDE [terraform-plan-destroy.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan-destroy.md)]
124+
125+
## Troubleshoot Terraform on Azure
126+
127+
[Troubleshoot common problems when using Terraform on Azure](/azure/developer/terraform/troubleshoot)
128+
129+
## Next steps
130+
131+
> [!div class="nextstepaction"]
132+
> [Set up push notifications in Azure Notification Hubs](configure-notification-hub-portal-pns-settings.md)

0 commit comments

Comments
 (0)