Quickstart: Create a notification hub using a Resource Manager template

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.

An Azure Resource Manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. You describe your intended deployment without writing the sequence of programming commands to create the deployment.

This quickstart uses an Azure Resource Manager template to create an Azure Notification Hubs namespace, and a notification hub named MyHub within that namespace.

If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.

Button to deploy the Resource Manager template to Azure.

Prerequisites

If you don't have an Azure subscription, create a free account before you begin.

Review the template

The template used in this quickstart is from Azure Quickstart Templates.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.8.9.13224",
      "templateHash": "2713724900359552876"
    }
  },
  "parameters": {
    "namespaceName": {
      "type": "string",
      "metadata": {
        "description": "The name of the Notification Hubs namespace."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "The location in which the Notification Hubs resources should be deployed."
      }
    }
  },
  "variables": {
    "hubName": "MyHub"
  },
  "resources": [
    {
      "type": "Microsoft.NotificationHubs/namespaces",
      "apiVersion": "2017-04-01",
      "name": "[parameters('namespaceName')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Free"
      }
    },
    {
      "type": "Microsoft.NotificationHubs/namespaces/notificationHubs",
      "apiVersion": "2017-04-01",
      "name": "[format('{0}/{1}', parameters('namespaceName'), variables('hubName'))]",
      "location": "[parameters('location')]",
      "properties": {},
      "dependsOn": [
        "[resourceId('Microsoft.NotificationHubs/namespaces', parameters('namespaceName'))]"
      ]
    }
  ]
}

Deploy the template

Select the following image to sign in to Azure and open a template. The template takes a Notification Hubs namespace name as a parameter. The template then creates a namespace with that name and a notification hub named MyHub within that namespace.

Button to deploy the Resource Manager template to Azure.

Review deployed resources

You can either use the Azure portal to check the deployed resources, or use Azure CLI or Azure PowerShell script to list the deployed Notification Hubs namespace and hub:

Get-AzNotificationHub -Namespace "nhtestns123" -ResourceGroup "ContosoNotificationsGroup"
Get-AzNotificationHubsNamespace -Namespace "nhtestns123"

The output looks similar to:

Verify deployment


Clean up resources

When no longer needed, delete the resource group, which deletes the resources in the resource group.

$resourceGroupName = Read-Host -Prompt "Enter the resource group name"
Remove-AzResourceGroup -Name $resourceGroupName
Write-Host "Press [ENTER] to continue..."

Next steps

For a step-by-step tutorial that guides you through the process of creating a template, see: