Chnage Backend Targets with Azure cli

SLIMANI Smail 60 Reputation points
2023-12-26T09:06:05.14+00:00

Hello,

I have application gateway and I need to change the backend targets of my rule using Azure CLI.
I have This configuration:

User's image

There will be two changes to be made at the backend level: the first one related to the url-path-map, and the second one related to the PathRules.

The first one woked with this commande:

az network application-gateway url-path-map update --resource-group "resourceGroupName" --gateway-name "gatewayName" -n "my-url-path" --default-address-pool "backend-app-maintenance" --default-http-settings "maintenance-http443"

But, I can't change the backend for my pathRules, I try some commande like that:

az network application-gateway url-path-map update --resource-group "resourceGroupName" \--gateway-name "gatewayName" -n "my-url-path" --default-address-pool "backend-app-maintenance" \--default-http-settings "maintenance-http443" \--set path_rules[0].backend_address_pool=backend-app-maintenance--set path_rules[0].backend_http_settings=maintenance-http443


Expect <class 'dict'>, got backend-app-maintenance (<class 'str'>)

Do you have any scripte or any idea to do this change ?

Regards,

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,217 questions
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. KapilAnanth-MSFT 49,611 Reputation points Microsoft Employee Moderator
    2023-12-26T14:07:04.71+00:00

    @SLIMANI Smail OBS/DD

    Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.

    Based on your CLI Query,

    • path_rules[0].backend_address_pool should be path_rules[0].backend_address_pool.id
    • path_rules[0].backend_http_settings should be path_rules[0].backend_http_settings.id
    • And in both the cases, you must input the entire resource ID of the resources.

    i.e.,

    • backend_address_pool will have '/subscriptions/<SUBSID>/resourceGroups/<RGNAME>/providers/Microsoft.Network/<APPGWNAME>/appgw/backendAddressPools/<BACKENDPOOLNAME>'
    • backend_http_settings will have '/subscriptions/<SUBSID>/resourceGroups/<RGNAME>/providers/Microsoft.Network/<APPGWNAME>/appgw/backendHttpSettingsCollection/<HTTPSETTINGSNAME>'

    Of course, you can entire input the entire path or get the values of each of this and store it in a variable and pass the variable.id to the command.

    Kindly let us know if this helps or you need further assistance on this issue.

    Thanks,

    Kapil


    Please don’t forget to close the thread by clicking "Accept the answer" wherever the information provided helps you, as this can be beneficial to other community members.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.