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