2016-11-25 74 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