0

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

2
  • github.com/Azure/azure-sdk-for-python/blob/master/… - code; models needed to do that - github.com/Azure/azure-sdk-for-python/blob/master/…. ping me if you won't be able to do that Commented Mar 9, 2017 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 Commented Mar 9, 2017 at 15:48

1 Answer 1

1

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

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)

Sign up to request clarification or add additional context in comments.

4 Comments

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?
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 ?
I edited adding how to get an IP from a VM object. Hope this helps.
Thanks, will try it :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.