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
Asked
Active
Viewed 836 times
0

Yordan Yordanov
- 201
- 1
- 2
- 6
-
https://github.com/Azure/azure-sdk-for-python/blob/master/azure-mgmt-network/azure/mgmt/network/operations/application_gateways_operations.py - code; models needed to do that - https://github.com/Azure/azure-sdk-for-python/blob/master/azure-mgmt-network/azure/mgmt/network/models/application_gateway.py. ping me if you won't be able to do that – 4c74356b41 Mar 09 '17 at 15:21
-
I've already found this, the problem is that it is not specified which parameters are required. I'm experiencing problems with the actual configuration and I cannot understand with which parameter exactly, because the error returned is "TypeError: string indices must be integers, not str". I have no errors in my code which can raise this error. I assume that it is returned by some kind of config validator – Yordan Yordanov Mar 09 '17 at 15:48
1 Answers
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)

Laurent Mazuel
- 3,422
- 13
- 27
-
I was able to create the Application gateway, the probelm is that for backend_address_pools I had to hardcode IP address('backend_addresses':[{'ip_address':'10.0.2.7'). Is there any way to set those addresses dynamically. How to uderstand which private IP addresses will be given to the VMs I create so I can put them in the backend addresses property? – Yordan Yordanov Mar 10 '17 at 13:30
-
I found that the IP addresses are allocated in order(starting from 4-th address) a way to fix the problem is counting VMs which will be created and adding addresses(2 vms = backend pool with Ip last symbols 4 and 5) is there a better way ? – Yordan Yordanov Mar 10 '17 at 14:27
-
I edited adding how to get an IP from a VM object. Hope this helps. – Laurent Mazuel Mar 10 '17 at 21:23
-