是否可以通过编程方式或通过 CLI 将 APNS 证书上传到 azure 通知中心
Is it possible to upload APNS Certificates to the azure notification hub programatically or via the CLI
我们正在调查 azure 通知中心,虽然我们从它那里获得了成功的 sending/receiving 消息,但我们还需要对中心进行编程配置。
似乎创建通知中心的唯一方法是通过带有 azuredeploy.json ARM 模板的 azure cli,例如 this one。但是,我找不到任何有关向其添加 APNS 证书的信息。
查看从我们的集线器生成的自动化脚本,没有 google firebase API 密钥或 APNS 证书的证据。这是否可能,或者这些是否需要始终通过 Azure 门户完成。
更新:我已经成功地使用 arm 模板创建了一个通知中心命名空间,没有什么问题,但是我在尝试时得到了 "bad request"(关联 ID - 3faee649-7084-436d-8d7e-4a9c6f79cc4e)使用 apns 证书创建通知中心本身。
this post 有人有类似的问题,但是他们的 apns 密钥比我的短很多。我从字面上创建了一个错误的 5000 多个字符的证书文件的 base64 字符串,我认为这是不正确的,但我无法弄清楚 apple 的值是什么意思。
我的模板是这样的:
{
"$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": {
}
}
在 apnsCredentials 属性 中,apsnCertificate 是来自文件的 base64 字符串,certificatekey 是您的证书密码,需要是一个强密码。你关注的是同一个吗?
此外,您是否看到了内部错误消息。如果是,那是什么?
谢谢,
阿莫尔
我们正在调查 azure 通知中心,虽然我们从它那里获得了成功的 sending/receiving 消息,但我们还需要对中心进行编程配置。
似乎创建通知中心的唯一方法是通过带有 azuredeploy.json ARM 模板的 azure cli,例如 this one。但是,我找不到任何有关向其添加 APNS 证书的信息。
查看从我们的集线器生成的自动化脚本,没有 google firebase API 密钥或 APNS 证书的证据。这是否可能,或者这些是否需要始终通过 Azure 门户完成。
更新:我已经成功地使用 arm 模板创建了一个通知中心命名空间,没有什么问题,但是我在尝试时得到了 "bad request"(关联 ID - 3faee649-7084-436d-8d7e-4a9c6f79cc4e)使用 apns 证书创建通知中心本身。
this post 有人有类似的问题,但是他们的 apns 密钥比我的短很多。我从字面上创建了一个错误的 5000 多个字符的证书文件的 base64 字符串,我认为这是不正确的,但我无法弄清楚 apple 的值是什么意思。
我的模板是这样的:
{
"$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": {
}
}
在 apnsCredentials 属性 中,apsnCertificate 是来自文件的 base64 字符串,certificatekey 是您的证书密码,需要是一个强密码。你关注的是同一个吗?
此外,您是否看到了内部错误消息。如果是,那是什么?
谢谢, 阿莫尔