我正在尝试使用 Python SDK 在 Azure 中创建公共(public) IP 地址,但我不明白为什么会收到错误。 这是我的代码:
netclient.public_ip_addresses.create_or_update('testgrp','testsdknic',{'location':'uksouth','sku':'standard','public_ip_allocation_method':'dynamic','public_ip_address_version':'ipv4'})
这是我得到的错误:
SerializationError: Unable to build a model: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get', DeserializationError: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'
我已经尝试了几种方法,但是虽然我成功创建了网络接口(interface),但无法创建公共(public) IP。 有人可以在这里给我一些指导吗? 非常感谢。
最佳答案
这个问题是由公网IP地址的属性sku
引起的,它是字符串,但是是PublicIPAddressSku
。所以你需要将代码改为:
netclient.public_ip_addresses.create_or_update('testgrp','testsdknic',{'location':'uksouth',
'sku':{'name': 'standard'},'public_ip_allocation_method':'static','public_ip_address_version':'ipv4'})
请注意,当您使用标准
作为公共(public)IP地址时,它应该采用静态
分配方法。
关于python - Azure:使用 Python 创建公共(public) IP 地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61275300/