As I work on setting up an Azure CDN endpoint using CDKTF, I've hit a roadblock with an error that I'm unable to troubleshoot. The error message I'm seeing states: Error: creating Endpoint: (Name "test" / Profile Name "test-profile" / Resource Group "test-rg"): cdn.EndpointsClient#Create: Failure sending request: StatusCode=400 -- Original Error: Code="BadRequest" Message="HostName "https://testmain.z6.web.core.windows.net/" is invalid. It must be a valid domain name, IP version 4, or IP version 6."
const cdnProfile =
new CdnProfile(this, env.CreateId(profileNameId), {
name: env.CreateId(profileNameId),
location: 'Global',
sku: SkuType.Premium_Verizon,
resourceGroupName: resGroup.name,
});
const hostName = mainStorageAccount.primaryWebEndpoint.replace(/^https?:\/\//, '').replace(/\/$/, '');
const cdnEndpointConfig = {
name: env.CreateId(cdnEndpointId),
profileName: cdnProfile.name,
location: Region.WEST_EUROPE,
resourceGroupName: resGroup.name,
querystringCachingBehaviour: 'NotSet',
optimizationType: 'GeneralWebDelivery',
isCompressionEnabled: false,
origin: [
{
name: mainStorageAccount.name,
hostName: hostName,
httpPort: 80,
httpsPort: 443,
},
],
};
new CdnEndpoint(this, cdnEndpointConfig.name, cdnEndpointConfig);
I'm seeking guidance on how to correctly format the hostName
to meet the specifications for a valid domain name in order to successfully create the CDN endpoint. Any assistance on this matter would be greatly appreciated.