是否可以以编程方式或通过CLI将APNS证书上载到azure通知中心

时间:2017-11-23 12:28:08

标签: azure azure-resource-manager azure-notificationhub

我们正在调查azure通知中心,虽然我们已成功发送/接收消息,但我们还需要对集线器进行编程配置。

似乎创建通知中心的唯一方法是使用azuredeploy.json ARM模板(如this one)通过azure cli。但是,我找不到有关向其添加APNS证书的任何信息。

查看从我们的中心生成的自动化脚本,没有证据显示google firebase API密钥或APNS证书。这是可能的,还是需要在任何时候都通过天蓝色门户网站完成。

更新:我已经设法使用arm模板创建了一个通知中心命名空间,但是在尝试创建时,我收到了一个“错误请求”(相关ID - 3faee649-7084-436d-8d7e-4a9c6f79cc4e)通知中心本身带有apns证书。

this post是一个有类似问题的人,但是他们的关键是apns比我的短很多。我从证书文件中创建了一个base64字符串,这个字符串有5000多个错误,我认为这是不正确的,但我无法弄清楚苹果的价值是什么意思。

我的模板如下所示:

    {
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "Gcm.GoogleApiKey": {
      "type": "string",
      "metadata": {
        "description": "Google Cloud Messaging API Key"
      },
      "defaultValue": ""
    },
    "Apns.apnsCertificate": {
        "type": "string",
        "metadata": {
          "description": "A certificate (in base 64 format) provided by Apple on the iOS Provisioning Portal"
        }
      },
      "Apns.certificateKey": {
        "type": "string",
        "metadata": {
          "description": "The Certificate Key provided by the iOS Provisioning Portal when registering the application"
        },
        "defaultValue": ""
      },
      "Apns.endpoint": {
        "type": "string",
        "metadata": {
          "description": "The APNS endpoint to which our service connects. This is one of two values: gateway.sandbox.push.apple.com for the sandbox endpoint or gateway.push.apple.com, for the production endpoint. Any other value is invalid"
        },
        "defaultValue": "gateway.sandbox.push.apple.com"
      }
  },
  "variables": {
    "hubVersion": "[providers('Microsoft.NotificationHubs', 'namespaces').apiVersions[0]]",
    "notificationHubNamespace": "[concat('hubv2', uniqueString(resourceGroup().id))]",
    "notificationHubName": "notificationhub"
  },
  "resources": [
    {
      "name": "[variables('NotificationHubNamespace')]",
      "location": "[resourceGroup().location]",
      "type": "Microsoft.NotificationHubs/namespaces",
      "apiVersion": "2017-04-01",
      "comments": "Notification hub namespace",
      "properties": {
        "namespaceType": "NotificationHub"
      },
      "resources": [
        {
          "name": "[concat(variables('NotificationHubNamespace'),'/',variables('NotificationHubName'))]",
          "location": "[resourceGroup().location]",
          "type": "Microsoft.NotificationHubs/namespaces/notificationHubs",
          "apiVersion": "2017-04-01",
          "properties": {
            "GcmCredential": {
              "properties": {
                "googleApiKey": "[parameters('Gcm.GoogleApiKey')]",
                "gcmEndpoint": "https://android.googleapis.com/gcm/send"
              }
            },
            "apnsCredential": {
                "properties": {
                    "apnsCertificate" : "[parameters('Apns.apnsCertificate')]",
                    "certificateKey" : "[parameters('Apns.certificateKey')]",
                    "endpoint" : "[parameters('Apns.endpoint')]"
                }
            }
          },
          "dependsOn": [
            "[concat('Microsoft.NotificationHubs/namespaces/', variables('NotificationHubNamespace'))]"
          ]
        }
      ]
    }
  ],
  "outputs": {
  }
}

1 个答案:

答案 0 :(得分:1)

在apnsCredentials属性中,apsnCertificate是来自file的base64字符串,certificatekey是您的证书密码,需要是强密码。你跟着一样吗?

此外,您是否看到内部错误消息。如果是,那是什么?

谢谢, AMOL