How can I disable health probe of an instance in a VMSS using Python so that the application gateway stops sending new requests to that instance?

Shobhana Sriram 0 Reputation points
2023-04-06T13:55:35.44+00:00

I have an application gateway which has a backend pool configured. The backend pool points to a VMSS which contains multiple instances. Health probe is also configured. When I want to downscale the VMSS instances from say 4 to 3, I want the application gateway to stop sending new requests to the instance which gets selected for deletion. I have been told that I need to listen to the terminate events and disable the health probe on that instance to achieve this. How can I disable the health probe of an instance in a VMSS using Python scripts? I have tried the following, but there is an error which indicates that there is no "update" option available on the VMSS. Error: AttributeError: 'VirtualMachineScaleSetVMsOperations' object has no attribute 'update' I am running this on a Ubuntu 20.04 instance. I installed these libs: pip3 install azure-mgmt-compute pip3 install msrestazure Code is shown below; please help me to fix this

from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.compute import ComputeManagementClient

subscription_id = 'subs_id'
credentials = ServicePrincipalCredentials(
    client_id='client_id',
    secret='secret',
    tenant='tenant_id'
)

compute_client = ComputeManagementClient(
    credential=credentials,
    subscription_id=subscription_id
)

compute_client.virtual_machine_scale_set_vms.update(
    resource_group_name='my_rg',
    vm_scale_set_name='vmss_name',
    instance_id='instance_id',
    parameters={
        'additional_capabilities': {
            'ultra_performance_enabled': False,
            'accelerated_networking_enabled': False
        }
    }
)
Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
952 questions
Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
344 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Micheal Falowo 6 Reputation points
    2023-04-15T21:23:08.2366667+00:00

    I think by default, when VMSS scales in, there's a grace period for when an instance is fully deleted. usually a minute of there about. in that Period, when app gateway probes the instance that's been deleted, the probe fails and hence probing continues until the threshold is met within the interval specified. A good way to fix this is to increase the probe threshold and increase the interval in other to account for the time it takes for the instance to be fully deleted so that app gateway stops sending probe to that instance. FYI, I will use 127.0.0.1 as the probe host.

    0 comments No comments