0

我正在使用以下azuredeploy.json文件来设置Azure云上的通知中心。如何在臂模板中配置APNS.Certificate

{ 
    "$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": "AIzaSyAyp9MernKgMS3wFNM3yNWByiP-TaGrqEg" 
     }, 
     "APNS.Certificate": { 
      "type": "string", 
      "metadata": { 
       "description": "A certificate (in base 64 format) provided by Apple on the iOS Provisioning Portal" 
      }, 
      "defaultValue": "" 
     }, 
     "APNS.certificateKey": { 
      "type": "string", 
      "metadata": { 
       "description": "The Certificate Key provided by the iOS Provisioning Portal when registering the application" 
      }, 
      "defaultValue": "ce469bf21dfa7b9d595d4999bfaca8a94ea47e46" 
     }, 
     "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." 
      }, 
      "allowedValues": [ 
       "gateway.sandbox.push.apple.com", 
       "gateway.push.apple.com" 
      ], 
      "defaultValue": "gateway.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": "[variables('hubVersion')]", 
      "comments": "Notification hub namespace", 
      "properties": { 
       "namespaceType": "NotificationHub" 
      }, 
      "resources": [ 
       { 
        "name": "[concat(variables('NotificationHubNamespace'),'/',variables('NotificationHubName'))]", 
        "location": "[resourceGroup().location]", 
        "type": "Microsoft.NotificationHubs/namespaces/notificationHubs", 
        "apiVersion": "[variables('hubVersion')]", 
        "properties": { 
         "GcmCredential": { 
          "properties": { 
           "googleApiKey": "[parameters('Gcm.GoogleApiKey')]", 
           "gcmEndpoint": "https://android.googleapis.com/gcm/send" 
          } 
         } 
        }, 
        "dependsOn": [ 
         "[variables('NotificationHubNamespace')]" 
        ] 
       } 
      ] 
     } 
    ], 
    "outputs": { 
    } 
} 

现在我试图建立苹果推送通知服务也使用下面的代码片断:

"apnsCredential": { 
       "properties": { 
       "apnsCertificate": "[parameters('APNS.Certificate')]", 
       "certificateKey": "[parameters('APNS.certificateKey')]", 
       "endpoint": " gateway.sandbox.push.apple.com or gateway.push.apple.com", 
       } 
      } 

利用上述变化,我使用powershell命令提示和上执行的部署-AzureResourceGroup.ps1执行它我收到错误消息“错误的请求”

任何人都可以帮助我解决此问题。

+0

需要比“错误的请求” –

+0

更多信息,你有没有得到这个工作? – OffHeGoes

回答

0

如果不知道更多关于环境/设置的信息,不可能确切知道是什么造成的。据this post,一个可能的问题可能是你的密码强度:

拉我的头发,并没有得到任何 超越“错误的请求”几个小时后,我终于想到要使用密码更强 比“pass @ word1”要好。我会感到厌烦,它的工作。不仅如此,但 使用Azure资源管理器进行配置是异步的,因此您的 脚本比以前更快地完成了很多工作,因为并行配置了虚拟机 。

该帖子推荐通过Troubleshooting common Azure deployment errors with Azure Resource Manager

0

我不确定您应该为您的模板动态设置apiVersion。它们根据您部署的内容而有所不同。

Best Practices:使用资源类型的API版本参数或变量

避免。资源属性和值可能因版本号而异。当API版本设置为参数或变量时,代码编辑器中的IntelliSense无法确定正确的模式。相反,在模板中对API版本进行硬编码。

正确apiVersion通知中心似乎是2015-04-01https://github.com/Azure/azure-resource-manager-schemas/blob/master/schemas/2015-04-01/Microsoft.NotificationHubs.json