Joe*_*aus 5 json azure azure-resource-manager azure-automation azure-rm-template
作为模板的一部分,我想要检索OMS/Operational Insights工作区的SharedKeys,而不是必须将其作为参数传递.
这可能吗?我在这里关注文档
Microsoft.OperationalInsights/workspaces/资源提供程序似乎没有任何list*提供程序操作,我找不到任何其他的引用:
Get-AzureRmProviderOperation -OperationSearchString * | where {$_.Operation -like "*operational*sharedkeys*"} | FT Operation
Microsoft.OperationalInsights/workspaces/sharedKeys/action
Run Code Online (Sandbox Code Playgroud)
我想要的用法:
"variables": { workspaceKey: "[listKeys(parameters('workspaceResourceId'), '2015-05-01-preview').primarySharedKey]" }
Run Code Online (Sandbox Code Playgroud)
在此期间,假设实际上不支持此功能,我在Log Analytics UserVoice站点上添加了对它的请求
根据Ryan Jones,[listKeys()]OMS Workspace将按预期工作并返回带有primarySharedKey&secondarySharedKey属性的JSON对象:
"outputs": {
"listKeys": {
"value": "[listKeys(parameters('workspaceResourceId'), '2015-11-01-preview')]",
"type": "object"
}
}
Run Code Online (Sandbox Code Playgroud)
收益率:
{
"primarySharedKey":"",
"secondarySharedKey":""
}
Run Code Online (Sandbox Code Playgroud)
listKeys()不能在
variablesARM模板的部分中指定,因为它从运行时状态派生其值.
或者,您可以直接使用它.这是我的最终模板:(
实际上不要将键保存在输出中!)
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workspaceResourceId": { "type": "string" },
"virtualMachines": { "type": "array" }
},
"variables": {
"extensionType": {
"Windows": "MicrosoftMonitoringAgent",
"Linux": "OmsAgentForLinux"
}
},
"resources": [
{
"copy": {
"name": "VMMonitoringExtensionsCopy",
"count": "[length(parameters('virtualMachines'))]"
},
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2015-05-01-preview",
"location": "[parameters('virtualMachines')[copyIndex()].location]",
"name": "[concat(parameters('virtualMachines')[copyIndex()].name, '/Microsoft.EnterpriseCloud.Monitoring')]",
"properties": {
"publisher": "Microsoft.EnterpriseCloud.Monitoring",
"type": "[variables('extensionType')[parameters('virtualMachines')[copyIndex()].osType]]",
"typeHandlerVersion": "1.0",
"autoUpgradeMinorVersion": true,
"settings": {
"workspaceId": "[reference(parameters('workspaceResourceId'), '2015-11-01-preview').customerId]"
},
"protectedSettings": {
"workspaceKey": "[listKeys(parameters('workspaceResourceId'), '2015-11-01-preview').primarySharedKey]"
}
}
}
],
"outputs": {
"workspaceCustomerId": {
"value": "[reference(parameters('workspaceResourceId'), '2015-11-01-preview').customerId]",
"type": "string"
},
"workspacePrimarySharedKey": {
"value": "[listKeys(parameters('workspaceResourceId'), '2015-11-01-preview').primarySharedKey]",
"type": "securestring"
},
"workspaceSecondarySharedKey": {
"value": "[listKeys(parameters('workspaceResourceId'), '2015-11-01-preview').secondarySharedKey]",
"type": "securestring"
}
}
}
Run Code Online (Sandbox Code Playgroud)
数组参数virtualMachines遵循以下模式:
[
{ "name": "", "location": "", "osType": "" }
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1577 次 |
| 最近记录: |