4
votes

I am using arm template to deploy Azure NotificationHub Here is

 {
  "apiVersion": "2017-04-01",
  "type": "Microsoft.NotificationHubs/namespaces/notificationHubs",
  "name": "[parameters('notificationHub_name')]",
  "location": "[parameters('location')]",
  "properties": {
    "GcmCredential": {
      "properties": {
        "googleApiKey": "[parameters('googleApiKey')]",
        "gcmEndpoint": "[parameters('googleEndpoint')]"
      }
    },
    "ApnsCredential": {
      "properties": {
        "appId": "[parameters('apnsAppId')]",
        "appName": "[parameters('apnsAppNameId')]",
        "keyId": "[parameters('apnsKeyId')]",
        "token": "[parameters('apnsToken')]",
        "endpoint": "[parameters('apnsEndpoint')]"
      }
    }
  },
  "dependsOn": [
    "[resourceId('Microsoft.NotificationHubs/namespaces', parameters('notificationHub_namespace'))]"
  ]
}

But I got error without details BadRequest

{
  "code": "DeploymentFailed",
  "details": [
     {
      "code": "BadRequest",
      "message": {
         "error": {
           "message": "Bad Request",
           "code": "BadRequest"
         }
      } 
    ]
  }

I test my parameters from azure portal and it works - so I assume that parameters are correct.

The question is how to deploy NotificationHub with ApnsCredentials using ARM?

1
Did you add "dependsOn": [ "[parameters('namespaceName')]" ] to notificationHubs?Tony Ju
Yes I got it, just it wasn't copied here.wolszakp

1 Answers

1
votes

Above arm template is correct.

My parameters were bad. I found solution by previewing requests sent from azure portal.

I was using endpoints for certificates:

  • Sandbox endpoint: gateway.sandbox.push.apple.com,
  • Production endpoint: gateway.push.apple.com

Endpoints for token authorization are different :

Here you can find details: https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-http2-token-authentification#configure-via-management-api-rest