Azure API Management can also manage internal APIs which are not accessible over the Internet. In this blog, we will learn
If you prefer to watch the video, here it is - A step by step guide on how to configure Azure API Management Internal Mode
With internal, we can inject Azure API Management instance into a virtual network and manage the APIs which can be accessed only with-in VNET Connected resources. When the internal mode is enabled in the Azure API Management instance, the access over the internet is completely blocked.
Couple of important points to be noted..
To understand this better, we need to know how the traffic flow in Internal Mode.
Inbound and Outbound traffic can be allowed to peered through virtual networks, Express Route, and VPN S2S Connections.
One of the most common use cases is
Managing On-premises API and providing secure access to the third parties which have connectivity to VNET (peered),
We can also manage both On-premises APIs and cloud-based APIs
For the purpose of demo, we will create two virtual machines in the same VNET as API Management instance. One VM will act as a web server with a API hosted. We will use this API as backend for our API Gateway and access it using API Gateway url from another virutal machine (client) inside the same VNET.
Access one of the APIs over the internet and test it.
Apply Inbound and Outbound traffic rules as shown below.
To make things easier, we create 2 certificates with the following PowerShell script. One of the certificates is a root certificate for signing, and the other is a wildcard certificate (CN=*.sri.com) for SSL bindings of the custom domain names.
# Create the root signing cert $root = New-SelfSignedCertificate -Type Custom -KeySpec Signature ` -Subject "CN=contoso-net-signing-root" -KeyExportPolicy Exportable ` -HashAlgorithm sha256 -KeyLength 4096 ` -CertStoreLocation "Cert:\CurrentUser\My" -KeyUsageProperty Sign ` -KeyUsage CertSign -NotAfter (get-date).AddYears(5) # Create the wildcard SSL cert. $ssl = New-SelfSignedCertificate -Type Custom -DnsName "*.sri.com","sri.com" ` -KeySpec Signature ` -Subject "CN=*.contoso.net" -KeyExportPolicy Exportable ` -HashAlgorithm sha256 -KeyLength 2048 ` -CertStoreLocation "Cert:\CurrentUser\My" ` -Signer $root # Export CER of the root and SSL certs Export-Certificate -Type CERT -Cert $root -FilePath .\sri-signing-root.cer Export-Certificate -Type CERT -Cert $ssl -FilePath .\sri-ssl.cer # Export PFX of the root and SSL certs Export-PfxCertificate -Cert $root -FilePath .\sri-signing-root.pfx ` -Password (read-host -AsSecureString -Prompt "password") Export-PfxCertificate -Cert $ssl -FilePath .\sri-ssl.pfx ` -ChainOption BuildChain -Password (read-host -AsSecureString -Prompt "password")
The certificate type is custom and select sri-ssl.pfx file created above and click save
Now in the API Management overview section, your can see configured custom domains.
With the above, the set-up is complete. let’s verify this.
Legal Stuff