python - Azure:使用 Python 创建公共(public) IP 地址

标签 python azure networking sdk ip

我正在尝试使用 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/

相关文章:

php - 我如何限制用户访问我的网站,而不是有许多分支机构的办公室

python - 从列表中获取第一个包含 'posts' 的 url

python - 包含 python 模块作为程序的一部分

azure - 为什么 RU 消耗高于预配置吞吐量与自动缩放最大吞吐量的比率?

python - Scapy转发包

linux - 树莓派拒绝连接到瓶服务器

python - 标签 python html

python - 值错误 : arrays must all be same length - print dataframe to CSV

c# - 跟踪、调试和信息消息未从 WorkerService 到达 App Insights

powershell - 如何以编程方式更改 Azure SQL 数据库的层