如何使用python SDK创建Azure应用程序网关 [英] How to create Azure Application gateway using python SDK

查看:89
本文介绍了如何使用python SDK创建Azure应用程序网关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始感到有点愚蠢.有人能够使用适用于Azure的Python SDK成功创建应用程序网关吗?该文档似乎还可以,但是我正在努力寻找正确的参数来传递参数的参数"azure.mgmt.network.operations.ApplicationGatewaysOperations application_gateways.create_or_update().我找到了一个load_balancer的完整工作示例,但找不到Application Gateway的任何内容.获取字符串索引必须是整数,而不是str"根本没有帮助.任何帮助将不胜感激,谢谢!

更新:已解决.为每个这样做的人提供的建议,请仔细查找应用程序网关参数所需的数据类型

I'm starting to feel a bit stupid. Have someone been able to successfully create an Application gateway using Python SDK for Azure? The documentation seems ok, but I'm struggling with finding the right parameters to pass 'parameters' of azure.mgmt.network.operations.ApplicationGatewaysOperations application_gateways.create_or_update(). I found a complete working example for load_balancer but can't find anything for Application gateway. Getting 'string indices must be integers, not str' doesn't help at all. Any help will be appreciated, Thanks!

Update: Solved. An advice for everyone doing this, look carefully for the type of data required for the Application gateway params

推荐答案

我知道目前没有适用于Application Gateway的Python示例,对此我表示歉意...现在,我建议您:

I know there is no Python sample for Application Gateway currently, I apologize for that... Right now I suggest you to:

  • Create the Network client using this tutorial or this one
  • Take a look at this ARM template for Application Gateway. Python parameters will be very close from this JSON. At worst, you can deploy an ARM template using the Python SDK too.
  • Take a look at the ReadTheDocs page of the create operation, will give you the an idea of what is expected as parameters.

Github跟踪器上打开一个问题,这样您就可以当我做一个样本(或至少可以模仿的单元测试)时,请遵循.

Open an issue on the Github tracker, so you can follow when I do a sample (or at least a unit test you can mimic).

在评论中的问题后进行

拥有VM对象后,要获取VM的IP:

To get the IP of VM once you have a VM object:

# Gives you the ID if this NIC
nic_id = vm.network_profile.network_interfaces[0].id
# Parse this ID to get the nic name
nic_name = nic_id.split('/')[-1]
# Get the NIC instance
nic = network_client.network_interfaces.get('RG', nic_name)
# Get the actual IP
nic.ip_configurations[0].private_ip_address

我终于写了样本:

https://github.com/Azure-Samples/network-python-manage-application-gateway

(我在微软工作,负责Python的Azure SDK)

(I work at MS and I'm responsible of the Azure SDK for Python)

这篇关于如何使用python SDK创建Azure应用程序网关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆