4

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?

wolszakp
  • 1,109
  • 11
  • 25

1 Answers1

1

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://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-http2-token-authentification#configure-via-management-api-rest

wolszakp
  • 1,109
  • 11
  • 25
  • My issue was that I had not declared an `endpoint` property at all. It's not required for the `gcmCredential`, but it is required for `apnsCredential`, regardless of whether you use token or certificate authentication. – James Jordan Taylor Jul 28 '21 at 21:24