我正在尝试通过ARM模板部署ServiceBus。香港专业教育学院尝试所有这些版本作为serviceBusNamespaceName值与相同的错误消息:
不起作用(使用名为'INT001-TestOrderStore-Cert'的资源组):
但始终会收到相同的错误消息:
2020-03-22T11:54:07.2612863Z ## [错误] BadRequest:{“错误”:{“ message”:“指定的服务名称空间无效。CorrelationId:43105e81-4248-41d6-ba91-9070e8ac4637”,“代码”:“ BadRequest”}}
这是迄今为止唯一有效的方法:“ sbnslau-1fa155e2-b3fb-48b9-a204-af1d2a02f40c”
因此,当我尝试使用concat和唯一字符串时,我需要了解出了什么问题。无论如何,在azure门户中是否可以评估表达式以解决其解析问题?
这是我的ARM的外观:
sbArmDeploy.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serviceBusNamespaceName": {
"type": "string",
"metadata": {
"description": "Name of the Service Bus namespace"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[parameters('serviceBusNamespaceName')]",
"type": "Microsoft.ServiceBus/namespaces",
"location": "[parameters('location')]",
"sku": {
"name": "Standard",
"tier": "Standard"
}
}
],
"outputs": {}
}
SbArmDeploy-Parameters.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serviceBusNamespaceName": {
"value": "sbns_1fa155e2-b3fb-48b9-a204-af1d2a02f40c"
}
}
}
[当我尝试使用您在Azure Portal中提供的名称(sbns_1fa155e2-b3fb-48b9-a204-af1d2a02f40c
)创建服务总线命名空间时,出现以下错误:
名称空间只能包含字母,数字和连字符。的名称空间必须以字母开头,并且必须以字母结尾或号
基本上,问题是名称空间名称中有下划线(_),这是不允许的。请删除该字符或将其更改为连字符(-),您将不会收到错误消息。
您可以在这里找到服务总线命名空间的命名规则:https://docs.microsoft.com/en-us/rest/api/servicebus/create-namespace。
正如评论中所讨论的,问题来了,因为您正在参数文件中定义变量。您需要做的是在主模板文件的“变量”部分中定义它们。
例如,这是我使用的ArmDeploy.json和Parameters.json文件:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"defaultValue": "[resourceGroup().location]",
"type": "String",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"serviceBusNamespaceName": "[concat('INT1001-ServiceBus-', uniqueString(resourceGroup().id))]"
},
"resources": [
{
"type": "Microsoft.ServiceBus/namespaces",
"apiVersion": "2017-04-01",
"name": "[variables('serviceBusNamespaceName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard",
"tier": "Standard"
}
}
],
"outputs": {}
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"value": "eastus"
}
}
}