没有 VM 资源的 Azure ARM 解决方案模板的初始化逻辑
Initialization logic of a Azure ARM solution template without VM resource
是否可以将 ARM 解决方案模板(createUiDefinition.json、azuredeploy.json 等)发布到 Azure Marketplace,它有应用服务和 CosmosDB 帐户资源但没有任何 VM具有初始化逻辑(例如创建 CosmosDB 数据库、集合)的资源,该逻辑在部署解决方案模板后执行。
如果解决方案模板包含 VM,则可以使用自定义脚本扩展,但有没有没有 VM 的方法?
我不确定你到底在追求什么,但我们正在使用 Azure Function 作为 arm 模板的一部分来配置 cosmosDb。这是它的工作原理:
"uri": "[concat('https://functionUrl?param1=', parameters('cosmosName'), '¶m2=', listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosName')), '2016-03-31').primaryMasterKey, '&code=', parameters('functionKey'))]"
这将调用 Azure Function 并为其提供 cosmosDb 名称和密钥,您可以在 Azure Function 中使用它来连接到 cosmosDb 并对其进行配置。唯一需要注意的是你的函数应该 return 空模板(或者不为空,只能被引擎解析)。
var template = @"{'$schema': 'https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#', 'contentVersion': '1.0.0.0', 'parameters': {}, 'variables': {}, 'resources': []}";
HttpResponseMessage myResponse = req.CreateResponse(HttpStatusCode.OK);
myResponse.Content = new StringContent(template, System.Text.Encoding.UTF8, "application/json");
return myResponse;
是否可以将 ARM 解决方案模板(createUiDefinition.json、azuredeploy.json 等)发布到 Azure Marketplace,它有应用服务和 CosmosDB 帐户资源但没有任何 VM具有初始化逻辑(例如创建 CosmosDB 数据库、集合)的资源,该逻辑在部署解决方案模板后执行。
如果解决方案模板包含 VM,则可以使用自定义脚本扩展,但有没有没有 VM 的方法?
我不确定你到底在追求什么,但我们正在使用 Azure Function 作为 arm 模板的一部分来配置 cosmosDb。这是它的工作原理:
"uri": "[concat('https://functionUrl?param1=', parameters('cosmosName'), '¶m2=', listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosName')), '2016-03-31').primaryMasterKey, '&code=', parameters('functionKey'))]"
这将调用 Azure Function 并为其提供 cosmosDb 名称和密钥,您可以在 Azure Function 中使用它来连接到 cosmosDb 并对其进行配置。唯一需要注意的是你的函数应该 return 空模板(或者不为空,只能被引擎解析)。
var template = @"{'$schema': 'https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#', 'contentVersion': '1.0.0.0', 'parameters': {}, 'variables': {}, 'resources': []}";
HttpResponseMessage myResponse = req.CreateResponse(HttpStatusCode.OK);
myResponse.Content = new StringContent(template, System.Text.Encoding.UTF8, "application/json");
return myResponse;