Search code examples
azure-api-managementazure-cli

Retrieve Private Ip address of API management using azure Cli


I am trying to read private ip address of api management on console using azure cli command but output is coming as blank none of the below command is working - az apim show -n -g --query "networkConfigurations[0].privateIpAddress[0]" az apim show -n -g --query "privateIPAddressesConfiguration[0].privateIpAddress" Does anyone know If the command is correct if not please share the correct command

Tried running the below commands -

az apim show -n <name> -g <group> --query "networkConfigurations[0].privateIpAddress[0]"
az apim show -n <name> -g <group> --query "privateIPAddressesConfiguration[0].privateIpAddress"

Solution

  • I am trying to read private ip address of api management on console using azure cli command but output is coming as blank.

    You need to use privateIpAddresses instead of privateIpAddress in your query as if you will run simply az apim show -n <name> -g <group> command, you will see the parameter name is privateIpAddresses.

    You can use any of these queries to get the private IP address of APIM.

    az apim show -n <APIM_Instance_Name> -g <Resource_Group>  --query "privateIpAddresses"
    or
    az apim show -n <APIM_Instance_Name> -g <Resource_Group>  --query "privateIpAddresses[0]"
    or
    az apim show -n <APIM_Instance_Name> -g <Resource_Group>  --query "privateIpAddresses" -o tsv
    

    Output

    enter image description here