2016-11-25 78 views
0

我在ARM模板:ARM模板CONCAT资源

"parameters": { 
    "applications": { 
     "value": "app1|app2|...|app(n)" 
    } 
}, 
"variables": { 
    "applications": "[split(parameters('applications'), '|')]" 
}, 

{ 
    "name": "[concat('notificationhub', copyIndex())]", 
    "type": "Microsoft.Resources/deployments", 
    "apiVersion": "2016-09-01", 
    "dependsOn": [ 
     "[concat('Microsoft.NotificationHubs/namespaces/',variables('notificationHubNamespace'))]" 
    ], 
    "copy": { 
     "name": "notificationhubCopy", 
     "count": "[length(variables('applications'))]" 
    }, 
    "parameters": { 
     "notificationHubNamespace": { "value" : "variables('notificationHubNamespace')]" }, 
     "notificationHubName": { "value": "[concat('notificationhub-', variables('applications')[copyIndex()])]" }, 
     ...   
     } 
    } 
}, 

如何Concat的创建notificationhub1和notificationhub2成一个值在应用程序的设置,如

“notificationhub1.connection | notificationhub2.connection | ... | notificationhub(n).connection“

或者有没有一个选项可以在应用程序设置中根据具有相应值的计数属性动态创建?

{ 
    "name": "[variables('webappName')]", 
    "type": "Microsoft.Web/sites", 
    "location": "[resourceGroup().location]", 
    "resources": [ 
    { 
     "name": "appsettings", 
     "type": "config", 
     "properties": { 
      "MobileApps": "[parameters('applications')]", 
      "NotificationHubs": "???", 
       -- OR -- 
      "App1NotificationHub": "notificationhub1.connection" 
      "App2NotificationHub": "notificationhub2.connection" 
      "App(n)NotificationHub": "notificationhubn(n).connection" 
     } 

    } 
}, 
+0

你想连接什么?资源ID? – 4c74356b41

+0

我想concat [listKeys('''Microsoft.EventHub/namespaces/authorizationRules','eventHubNamespaceName','keyName'),'2015-08-01')。primaryConnectionString] foreach应用程序。或者我使用其他方式在应用程序设置中包含每个应用程序的eventhub。 – Leszek

+0

concat用什么? – 4c74356b41

回答

0

我不能100%确定这一点,但看你有什么在这里这样的事情应该工作:

[concat(listKeys(resourceId('Microsoft.EventHub/namespaces/authoriz‌​ationRules', 'eventHubNamespaceName', 'keyName'),'2015-08-01').primaryConnectionString, '|', listKeys(resourceId('Microsoft.EventHub/namespaces/authoriz‌​ationRules', 'eventHubNamespaceName', 'keyName'),'2015-08-01').primaryConnectionString)] 

我无法验证如果eventhubs listkeys做的工作一样这个,但是当你弄清楚listkeys是如何工作的,你应该可以将它粘贴到上面的例子中。
另外'|'可能需要转义。我想逃跑是用\完成的。

编辑:再次,我不确定这一点,我从来没有尝试过,但你会想要使用这个link,并尝试使用通知集线器而不是存储帐户来重现它。

+0

硬编码的2应用程序值,这很好,但是这个值将被传递给模板。它可能是一个或十个。 “应用程序”:{ “value”:“app1 | app2 | ...” } – Leszek

+0

啊,我明白了。坚持下去,让我考虑一下。 – 4c74356b41