vnetapimazure-nsg

Failed to connect to management endpoint someresource.management.azure-api.net:3443 for a service deployed in a Virtual Network


In Terraform after adding the following NSG Rule, I still get an error message below, What could be the issue?

   resource "azurerm_network_security_rule" "someresource_nsg_rule_inbound" {
   name                        ="Management_Endpoint_for_Azure_Portal_and_Powershell"
   priority                    = 110
   direction                   = "Inbound"
   access                      = "Allow"
   protocol                    = "Tcp"
   source_port_range           = "*"
   destination_port_range      = "3443"
   source_address_prefix       = "ApiManagement"
   destination_address_prefix  = "VirtualNetwork"
   resource_group_name         = azurerm_resource_group.someresource_rg.name
   network_security_group_name = azurerm_network_security_group.someresource_nsg.name
   }
    
   ------
 
   │ Error: retrieving Policy for Service (Subscription: "xxxxxxxxxx"
   │ Resource Group Name: "SomeResource-Dev"
   │ Service Name: "someResource-dev-apim"): unexpected status 422 (422 Unprocessable 
    Entity) with error: ManagementApiRequestFailed: Failed to connect to management 
    endpoint someResource-dev-apim.management.azure-api.net:3443 for a service 
    deployed in a Virtual Network. Make sure to follow guidance at 
    https://aka.ms/apim-vnet-common-issues for Inbound connectivity to Management 
    endpoint. Check 'ApiManagement 
    Control Plane - inbound' connectivity at https://aka.ms/apimnetworkstatus.

  

Solution

  • Failed to connect to management endpoint someresource.management.azure-api.net:3443 for a service deployed in a Virtual Network

    If you are trying to connect to APIM as a inbound from another resource, need to use private endpoint connections. Follow the MS Doc for more details.

    enter image description here

    Once you create a public endpoint, disable public access to APIM using the cmdlet below.

    az apim update --name "APIM-NAME" --resource-group "RG-NAME" --public-network-access false
    

    APIM DNS details

    enter image description here

    When I try to access the API from an external network, access is being blocked

    enter image description here

    When I try to access the API within the same private endpoint network, the connection is established as shown below.

    enter image description here

    APIM DNS result from a VM connected to the same network.follow the MS Doc for more details

    enter image description here

    Refer: Connect privately to API Management using an inbound private endpoint