Introduction
This article will review the "InvalidResourceName" error you may encounter when setting up a peering connection between your HVN and your Azure Vnet and how to solve this issue. You can find our instructions on how to peer an Azure virtual network with HCP here.
Problem
While setting up your peering connection between your HVN and your Azure AD, you may run into the following error which prevents you from being able to finish the peering connection setup:
Error Code from Azure: InvalidResourceName
Resource name 1234567-1234-1234-1234-123456789012-to-MYHVN-MINE-CONNECT-VNET-12345678901234567890123 is invalid.
The name can be up to 80 characters long.
It must begin with a word character, and it must end with a word character or with ''. The name may contain word characters or '.', '-', ''.
Cause
The error happens since the name used for creating the peering is formatted as: “<HVN_name>-to-<VNET_name>
". Currently HCP limits the HVN name to 36 characters, but the Azure Vnet name limit is 80. Using more than 40 characters on the Azure VNet name will cause the error since the resource name limit for peering is 80 characters. ( 36 characters "HVN name" + 4 characters "-to-" + 40 characters "VNet name" = 80, which is the limit)
Solution
Please ensure that you use less than 40 characters to name your Azure VNet.