我正在寻找ARM部署存储帐户使用Python。也就是说,我正在寻找与powershell的new-azresourcegroupdeployment cmdlet相当的Python。
我一直在寻找一些链接,但我找不到任何。
这个链接,有一些‘部署程序’类,但它非常特定于linux。我认为应该有一个非常简单的方法来做到这一点。我找不到它。
发布于 2020-07-22 18:50:01
该示例将与任何模板一起工作,只需稍作修改。具体来说,Deployment.deploy()方法是您希望使用模板查找资源组部署示例的地方。
您需要更改的主要内容是属性。示例中的内容是特定于Linux模板的,因此需要将它们更改为存储模板中的模板,或者在模板中根本不使用参数的情况下删除它们。
def deploy(self):
"""Deploy the template to a resource group."""
self.client.resource_groups.create_or_update(
self.resource_group,
{
'location': 'westus'
}
)
template_path = os.path.join(os.path.dirname(
__file__), 'templates', 'template.json')
with open(template_path, 'r') as template_file_fd:
template = json.load(template_file_fd)
parameters = { #<------- Update this with your template's parameters
'sshKeyData': self.pub_ssh_key,
'vmName': 'azure-deployment-sample-vm',
'dnsLabelPrefix': self.dns_label_prefix
}
parameters = {k: {'value': v} for k, v in parameters.items()}
deployment_properties = {
'mode': DeploymentMode.incremental,
'template': template,
'parameters': parameters
}
deployment_async_operation = self.client.deployments.create_or_update(
self.resource_group,
'azure-sample',
deployment_properties
)
deployment_async_operation.wait()https://stackoverflow.com/questions/63033816
复制相似问题