1

How do I add an existing VM to an existing App gateway via the Python SDK for Azure?

I've looked at this, and used it too, to create an app gateway programatically, but how do I go about adding newly created VMs to the existing gateway?

1 Answer 1

0

You could check this answer.

Note: Firstly, your existing VM should be in your application gateway's VNet.

If you add your VM's public IP to application, you could use like below:

"backend_address_pools": [{
    "name": appgateway_backend_pool_name,
    "backend_addresses": [{
        "ip_address": "10.1.0.4"
    }, {
        "ip_address": "10.1.0.5"
    }]
}],

Check this example.

If you want to add VM's nic to application gateway, you need use like below:

"backend_address_pools": [{
    "name": appgateway_backend_pool_name,
    "backend_ip_configurations": [{
        "id": "/subscriptions/**********/resourceGroups/shuiapplication/providers/Microsoft.Network/networkInterfaces/shui361/ipConfigurations"
    }]
}],

Check Python SDK in this link.

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

12 Comments

Sorry, where do I add the attribute? While creating the NIC, or in the VM?
If you want to add VM's nic. Your VM and application gateway should be in the same VNet.
I understood that. I was actually asking where I add "backend_address_pools": [{ "name": appgateway_backend_pool_name, "backend_addresses": [{ "ip_address": "10.0.0.4" }, { "ip_address": "10.0.0.5" }] }],
I know what you mean. I will test it in my lab.
I test in my lab, you need create a param contain this. imgur.com/a/dbEGs. I test in my lab, they are all required. Then using network_client.application_gateways.create_or_update(rg,name,params_create) update your application gateway.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.