Share via


クイックスタート: Resource Manager テンプレートを使用して通知ハブを作成する

Azure Notification Hubs は、すべてのバックエンド (クラウドまたはオンプレミス) からすべてのプラットフォーム (iOS、Android、Windows、Kindle など) に通知を送信できる、使いやすいスケールアウトされたプッシュ エンジンです。 このサービスの詳細については、「Azure Notification Hubs とは」を参照してください。

Azure Resource Manager テンプレートは JavaScript Object Notation (JSON) ファイルであり、プロジェクトのインフラストラクチャと構成が定義されています。 このテンプレートでは、宣言型の構文が使用されています。 デプロイしようとしているものを、デプロイを作成する一連のプログラミング コマンドを記述しなくても記述できます。

このクイックスタートでは、Azure Resource Manager テンプレートを使用して、Azure Notification Hubs 名前空間と、その名前空間内に MyHub という名前の通知ハブを作成します。

環境が前提条件を満たしていて、ARM テンプレートの使用に慣れている場合は、 [Azure へのデプロイ] ボタンを選択します。 Azure portal でテンプレートが開きます。

Button to deploy the Resource Manager template to Azure.

前提条件

Azure サブスクリプションをお持ちでない場合は、開始する前に無料アカウントを作成してください。

テンプレートを確認する

このクイックスタートで使用されるテンプレートは Azure クイックスタート テンプレートからのものです。

{
  "$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'))]"
      ]
    }
  ]
}

テンプレートのデプロイ

Azure にサインインし、テンプレートを開くには次のイメージを選択します。 このテンプレートでは、Notification Hubs 名前空間名をパラメーターとして受け取ります。 次いで、このテンプレートではその名前の名前空間と、その名前空間内に MyHub という名前の通知ハブを作成します。

Button to deploy the Resource Manager template to Azure.

デプロイされているリソースを確認する

デプロイされたリソースは、Azure portal を使用して確認するか、Azure CLI または Azure PowerShell スクリプトを使用してデプロイされた Notification Hubs 名前空間とハブを一覧表示することができます。

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

出力は次のようになります。

Verify deployment


リソースをクリーンアップする

不要になったら、リソース グループを削除します。これにより、リソース グループ内のリソースが削除されます。

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

次のステップ

テンプレートの作成手順について説明したチュートリアルについては、次のページを参照してください。

初めての ARM テンプレートを作成してデプロイする[