Azure:使用 Python 创建 public ip 地址
Azure: Creating public ip address with Python
我正在尝试使用 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'
我尝试了几种方法,但在成功创建网络接口时,我无法创建 public IP。
有人可以在这里为我提供一些指导吗?
非常感谢。
对于这个问题,是public 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'})
请注意,当您使用 standard
作为 public IP 地址时,它应该在 static
分配方法中。
我正在尝试使用 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'
我尝试了几种方法,但在成功创建网络接口时,我无法创建 public IP。 有人可以在这里为我提供一些指导吗? 非常感谢。
对于这个问题,是public 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'})
请注意,当您使用 standard
作为 public IP 地址时,它应该在 static
分配方法中。