Lesson 3 of 5 Azure Key Vault

Configuring Key Vault Network Access

This lesson explains the vault firewall, the trusted services exception and private endpoints.

Learning outcomes

After completing this lesson, you will be able to:

  • Compare the network access positions.
  • Explain the limits of IP and virtual network rules.
  • Describe what the trusted services exception does and does not do.
  • Explain how a private endpoint restricts a vault.

Default network exposure

A new vault has a public endpoint, and its firewall is disabled, so it accepts connections from any address, provided that the caller is authenticated and authorized. Network restriction adds a second, independent condition. A stolen credential then cannot be used from an attacker's own network, which is valuable defence in depth.

The Networking page offers three broad positions, which the following table compares.

PositionWho can reach the data planeSuitable for
Allow public access from all networksAnyone authenticated and authorizedDevelopment vaults only
Allow public access from specific virtual networks and IP addressesListed subnets and public IPv4 ranges, plus trusted services if the exception is onWorkloads with fixed addresses or service endpoints
Disable public accessPrivate endpoints, plus trusted services if the exception is onProduction workloads

Network rules

A vault can hold up to 200 virtual network rules and 1,000 IPv4 rules. An IP rule admits a public IPv4 address or range. Private ranges from RFC 1918 are not allowed, because a request from inside a virtual network reaches the vault through a virtual network rule or a private endpoint instead. A virtual network rule depends on the Microsoft.KeyVault service endpoint on the subnet, which sends traffic over the Azure backbone and identifies the subnet to the vault.

The firewall applies to the data plane. A person can still view the vault in the portal, because that uses the control plane, but listing secrets from a home network will fail if the address is not allowed. This is why a blocked administrator sees a message in the portal saying that the operation is not allowed by the firewall, even with the right role.

Fill in the value

Firewall limits

Exam skills 1.2.4

Recall the limits of Key Vault network rules.

Log in to try this activity Interactive activities are free with an account.

The trusted services exception

Some Azure services connect to a vault from addresses that you cannot list. The setting Allow trusted Microsoft services to bypass this firewall admits a defined set of services, including Azure Backup, Azure Storage, Azure SQL, Azure Disk Encryption and Azure Resource Manager template deployment. The bypass works with public network access disabled, and no private endpoint is then needed for those services.

The list does not include everything. Azure DevOps, for example, is not on it, so a Microsoft-hosted agent reading a vault with the firewall on will fail, and it needs a self-hosted agent inside the network. A service that is not listed is blocked whether or not the exception is on. The exception does not grant permission either: the service must still have rights on the vault.

Trusted means listed

An option that says to enable the trusted services exception for a third-party or custom application is wrong. The exception applies only to Microsoft's listed first-party services.

Troubleshooting scenario

Blocked by the firewall

Exam skills 1.2.4

Resolve access failures after the vault firewall is turned on.

Log in to try this activity Interactive activities are free with an account.

Private endpoints

A private endpoint gives the vault a private IP address in a virtual network. Clients resolve VAULT.vault.azure.net through a private DNS zone named privatelink.vaultcore.azure.net to that private address. To force all traffic through it, disable public access.

az keyvault update --name VAULT --resource-group RG --public-network-access Disabled

A private endpoint is the strongest option, because the data path stays on private addressing, and because on-premises clients can use it through a VPN or ExpressRoute. Traffic through a private endpoint does not depend on the firewall's IP rules. Network Security Perimeter is a newer option that groups PaaS resources into a logical boundary, with rules for inbound and outbound access, and with the setting Secure by perimeter the trusted services bypass is overridden.

The following diagram shows the network paths a vault can admit.

Network paths to a vault's data plane. A public client is admitted by an IP rule for its public address. A workload in an Azure subnet is admitted by a virtual network rule through the Microsoft.KeyVault service endpoint. A private endpoint gives the vault a private address in a virtual network, and clients resolve the vault name through the privatelink.vaultcore.azure.net zone to it; with public access disabled, this is the only route. The firewall applies to the data plane, not to the portal's control-plane view.
A private endpoint keeps the data path on private addresses.
True or false

Private access to a vault

Exam skills 1.2.4

Check how private endpoints work with Key Vault.

Log in to try this activity Interactive activities are free with an account.
Worked example

Connecting an on-premises process

An on-premises scheduler connects through a site-to-site VPN and must read a secret. An Azure SQL logical server in the same subscription must use a key from the same vault for transparent data encryption. Public internet access to the vault must be blocked. What should you configure?

Disable public network access, and add a private endpoint in a virtual network that the VPN reaches. Configure on-premises DNS to resolve the vault's name to the private address, usually through a DNS forwarder for the privatelink.vaultcore.azure.net zone. Then turn on Allow trusted Microsoft services to bypass this firewall, as Azure SQL is on the list, and give the server's identity Key Vault Crypto Service Encryption User.

An IP rule with the on-premises private range is not possible, because private ranges are not allowed. A virtual network rule applies to subnets in Azure, not to traffic that arrives from on-premises, unless a private endpoint is used.

Check yourself

Why can an administrator with Key Vault Administrator fail to list secrets in the portal?

Show answer

The firewall may block the browser's address. It applies to the data plane, whatever role the person holds.

Exam Tips

Remember for the exam

  • The firewall is off by default on new vaults.
  • IP rules accept public IPv4 ranges only.
  • Trusted services means Microsoft's listed services, and they still need rights.
  • A blocked portal user with the right role usually has a firewall problem.