Azure API Management service with external virtual network to Docker

Enrico Rossini 246 Reputation points
2021-04-12T14:19:28.973+00:00

I want to use the Azure API Management Service (AMS) to expose the API created with R/Plumber hosted in a Docker container and runs in an Ubuntu machine.

Scenario

With R/Plumber I created some APIs that I want to protect. Then, I created a virtual machine on Azure with Ubuntu and installed Docker. The APIs are in a container that I published on the virtual machine by Docker. I can access them via internet.

On Azure I created an API Management service and added the APIs from the Swagger OpenAPI documentation.

YXcty.png

Problem

I want to secure the APIs. I want to expose to the internet only the AMS. Then, my idea was to remove the public IP from the virtual machine and via a virtual network using the internal IPs to connect the API Management Service to the API with the internal IP (http://10.0.1.5:8000).

So, I tried to set a Virtual Network. Clicked on the menu, then External and then on the row, I can select a network. In this virtual network, I have one network interface that is the one the virtual machine is using.

3pHc3.png

When I save the changes, I have to wait a while and then I receive an error

> Failed to connect to management endpoint at azuks-chi-testapi-d1.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.

8ZgrK.png

I read the following documentation but I can't understand how to do what I wanted

Is there any how-to to use? Any advice? What are I doing wrong?

Update

I tried to add more Address space in the Virtual network.

Up7NO.png

One of them (10.0.0.2/24) is delegate for the API Management.

ssv88.png

Then, in the Network security group I added the port 3443.

OSHmN.png

From the API manager I can't reach the server with the internet IP (10.0.2.5). What did I miss?

Azure API Management
Azure API Management

An Azure service that provides a hybrid, multi-cloud management platform for APIs.

Azure Virtual Machines
Azure Virtual Machines

An Azure service that is used to provision Windows and Linux virtual machines.

Azure Virtual Network
Azure Virtual Network

An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.


1 answer

Sort by: Oldest
  1. Mike Urnun 9,797 Reputation points Moderator
    2021-05-01T22:38:56.44+00:00

    Hello @Enrico Rossini - My apologies for the late response. I implemented your scenario and everything worked fine for me. In the NSG rule, the required protocol for port 3443 is of type TCP but you seem to have it as Any. This might fix the issue for you. Also, instead of importing the Swagger spec over public IP from the VM at the time of when the VNET configuration work for APIM wasn't completed, I opted to upload the Swagger file after both services were fully configured individually and then looked to establish connectivity between them. At that point, it was a matter of specifying the private IP in APIM to make it all work:
    93129-image.png

    Was this answer helpful?

    0 comments No comments

Your answer

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