How to create Azure Application gateway using python SDK

馋奶兔 提交于 2019-12-12 02:16:13

问题


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


回答1:


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.

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).

Edit after question in comment:

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

Edit:

I finally wrote the sample:

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

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



来源:https://stackoverflow.com/questions/42698609/how-to-create-azure-application-gateway-using-python-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!