2015-12-17 28 views
1

我使用ServiceBus,队列和耦合共享访问规则创建Azure资源管理器模板。我创建正确的命名空间和队列,但是当我尝试添加授权规则,我得到:Azure ServiceBus - 队列 - 授权规则创建错误

资源Microsoft.ServiceBus /命名空间/ authorizationRules “myservicebusnamespace/SendOnlyKey”与消息失败“请求 有效载荷不以预期的格式。

首先这是可能的吗?有没有样本,并做文档..

因为这是非常通用的消息,我想知道是否有其他人遇到类似的问题,使用ARM模板创建队列? 这是我到目前为止有:

{ 
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 
    "contentVersion": "1.0.0.0", 
    "parameters": { 
    "sbNamespace": { 
     "type": "string", 
     "metadata": { 
     "description": "The service bus namespace" 
     } 
    } 
    }, 
    "variables": { 
    "location": "[resourceGroup().location]", 
    "sbVersion": "[providers('Microsoft.ServiceBus', 'namespaces').apiVersions[0]]", 
    "queueName": "testQueue", 
    "defaultSASKeyName": "RootManageSharedAccessKey", 
    "authRuleResourceId": "[resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('sbNamespace'), variables('defaultSASKeyName'))]", 
    "sendAuthRuleResourceId": "[resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('sbNamespace'), 'SendOnlyKey')]", 
    "keyGeneratorTemplateUri": "https://raw.githubusercontent.com/sjkp/Azure.ARM.ServiceBus/master/Azure.ARM.ServiceBus/Templates/keygenerator.json" 
    }, 
    "resources": [ 
    { 
     "apiVersion": "2015-01-01", 
     "name": "primaryKey", 
     "type": "Microsoft.Resources/deployments", 
     "properties": { 
     "mode": "incremental", 
     "templateLink": { 
      "uri": "[variables('keyGeneratorTemplateUri')]", 
      "contentVersion": "1.0.0.0" 
     }, 
     "parameters": { 
      "seed": { "value": "1234a5" } 
     } 
     } 
    }, 
    { 
     "apiVersion": "2015-01-01", 
     "name": "secondaryKey", 
     "type": "Microsoft.Resources/deployments", 
     "properties": { 
     "mode": "incremental", 
     "templateLink": { 
      "uri": "[variables('keyGeneratorTemplateUri')]", 
      "contentVersion": "1.0.0.0" 
     }, 
     "parameters": { 
      "seed": { "value": "ac34a5" } 
     } 
     } 
    }, 
    { 
     //namespace 
     "apiVersion": "[variables('sbVersion')]", 
     "name": "[parameters('sbNamespace')]", 
     "type": "Microsoft.ServiceBus/namespaces", 
     "location": "[variables('location')]", 
     "properties": { 
     "messagingSku": 2 
     }, 
     "resources": [ 
     { 
      //queue 
      "apiVersion": "[variables('sbVersion')]", 
      "name": "[variables('queueName')]", 
      "type": "Queues", 
      "dependsOn": [ 
      "[concat('Microsoft.ServiceBus/namespaces/', parameters('sbNamespace'))]" 
      ], 
      "properties": { 
      "path": "[variables('queueName')]", 
      "defaultMessageTimeToLive": "14.0:0:0", 
      "maxQueueSizeInMegaBytes": "1024", 
      "maxDeliveryCount": "10" 
      } 
     } 
     ,{ 
      //auth rule 1 
      "apiVersion": "[variables('sbVersion')]", 
      "name": "[concat(parameters('sbNamespace'),'/SendOnlyKey')]", 
      "type": "Microsoft.ServiceBus/namespaces/authorizationRules", 
      "dependsOn": [ 
      "[concat('Microsoft.ServiceBus/namespaces/', parameters('sbNamespace'))]", 
      "[concat('Microsoft.Resources/deployments/', 'primaryKey')]", 
      "[concat('Microsoft.Resources/deployments/', 'secondaryKey')]" 
      ], 
      "location": "[variables('location')]", 
      "properties": { 
      "keyName": "SendOnlyKey", 
      "PrimaryKey": "[reference('primaryKey').outputs.key.value]", 
      "SecondaryKey": "[reference('secondaryKey').outputs.key.value]" 
      } 
     } 
     ] 
    } 
    ], 
    "outputs": { 
    "NamespaceDefaultConnectionString": { 
     "type": "string", 
     "value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryConnectionString]" 
    } 
    } 
} 

回答

1

听起来象是与应该生成密钥的子模板失败。

您可以尝试使用例如使用powershell代替:

$bytes = New-Object Byte[] 32 
$rand = [System.Security.Cryptography.RandomNumberGenerator]::Create() 
$rand.GetBytes($bytes) 
$rand.Dispose() 
$key = [System.Convert]::ToBase64String($bytes) 

查看是否修复了错误。

+0

它也可能是claimType是错误的。如果您没有使用发送权限创建授权规则,则只应使用claimType:“SharedAccessKey” – sjkp

+0

只需查看GitHub仓库中的新文件ServiceBusQueues.json - 看起来像我需要的,谢谢。 – Milen