【发布时间】:2022-01-12 03:41:15
【问题描述】:
我正在寻求解决尝试应用到我正在使用 python sdk 创建身份的 vm 的问题。代码:
print("Creating VM " + resource_name)
compute_client.virtual_machines.begin_create_or_update(
resource_group_name,
resource_name,
{
"location": "eastus",
"storage_profile": {
"image_reference": {
# Image ID can be retrieved from `az sig image-version show -g $RG -r $SIG -i $IMAGE_DEFINITION -e $VERSION --query id -o tsv`
"id": "/subscriptions/..image id"
}
},
"hardware_profile": {
"vm_size": "Standard_F8s_v2"
},
"os_profile": {
"computer_name": resource_name,
"admin_username": "adminuser",
"admin_password": "somepassword",
"linux_configuration": {
"disable_password_authentication": True,
"ssh": {
"public_keys": [
{
"path": "/home/adminuser/.ssh/authorized_keys",
# Add the public key for a key pair that can get access to SSH to the runners
"key_data": "ssh-rsa …"
}
]
}
}
},
"network_profile": {
"network_interfaces": [
{
"id": nic_result.id
}
]
},
"identity": {
"type": "UserAssigned",
"user_assigned_identities": {
"identity_id": { myidentity }
}
}
}
最后一部分,身份:我在网络上的某个地方找到了(不确定在哪里),但是当我尝试使用它时它失败了,出现了一些奇怪的设置/获取错误。如果我注释掉身份:块,虚拟机将创建良好,但我需要用户分配的身份。我今天大部分时间都在尝试查找有关 begin_create_or_update 选项的信息和有关身份的信息,但我没有运气。我正在寻求有关如何将用户分配的 python 标识应用于我正在创建的虚拟机的帮助。
【问题讨论】:
-
如果回答对您有帮助,请Accept it as an Answer,以便遇到相同问题的其他人可以找到此解决方案并解决他们的问题。
标签: python azure azure-virtual-machine