Unable to create Azure CDN Endpoint: HostName entered is invalid - Ensure it is a valid domain name, IP version 4, or IP version 6

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.

Answer №1

Important Information: For those facing a similar problem: Avoid wasting time on mainStorageAccount.primaryWebEndpoint and dealing with ineffective substitutions. Just utilize mainStorageAccount.primaryWebHost as the host name for your origin.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The partial template is not functioning as anticipated

Introducing an interface designed to accept two templates, with the resulting function being a partial of one of them (similar to React-Redux): export type IState<TState, TOwnProps> = { connect: (mapStateToProps: MapStateToProps<TState, Parti ...

An error occurs when attempting to use object mapping and the rest operator in a return statement due to

I've encountered a type mismatch error in my TypeScript project using Prisma while attempting to return an object with mapped properties in the getPool method. Let's take a look at the code snippet causing the issue: public async getPool({ id, v ...

Using a Type Guard in Typescript to check if an environment variable matches a key in a JSON object

I am currently working on creating a Type Guard to prevent TypeScript from throwing an error on the final line, where I attempt to retrieve data based on a specific key. TypeScript is still identifying the environment variable as a string rather than a rec ...

Challenges with promises in Angular Firebase Realtime DB

Having some difficulties with Angular and Firebase Realtime DB. In my database service, I created a function like this: getAllProject() { return firebase.database().ref('project').once('value').then((snapshot) => { if (snapsh ...

Explain the concept of a static async create method having identical parameters as the constructor

I have a lot of existing classes that require refactoring to utilize an async constructor. Here's an example: class ClassA { constructor(a: number, b: string, c: string) { //... } //... } I've included an async create method ...

Comparing Input and Output Event Binding

Can you provide reasons why using @Output for events is more advantageous than passing an @Input function in Angular 2+? Utilizing @Input: Parent Template: <my-component [customEventFunction]=myFunction></my-component> Inside parent-compone ...

TypeScript was looking for 'never' but found an intersection instead

Can someone help me understand why a conflicting type intersection did not produce a type of never? What am I overlooking? type A = {value: string} type B = {value: number} type D = A & B type E<T> = T extends never ? 'never' : ' ...

Exporting the default value from a TypeScript declaration file module

Imagine having a declaration file called foo.d.ts: declare namespace foo { interface Bar { (): void; } } declare var foo: foo.Bar; export default foo; Upon compilation: import Foo from './foo'; Foo(); The result is: "use strict"; va ...

An object resulting from the combination of two separate objects

After reading a helpful solution on StackOverflow about merging properties of JavaScript objects dynamically, I learned how to utilize the spread operator in Typescript. However, one question still remains unanswered - what will be the type of the object c ...

Does the React memo function modify the component's prop type?

I've come across a strange issue where defining two components causes compilation errors when written separately but not when written in the same file. test3.tsx import React from "react"; type ValueType = number[] | string[] | number | st ...

What is the best way to set up a property in a service that will be used by multiple components?

Here is an example of how my service is structured: export class UserService { constructor() {} coords: Coordinates; getPosition() { navigator.geolocation.getCurrentPosition(position => { this.coords = [position.coords.latitude, posit ...

The Karma testing feature in Angular Quickstart encounters issues right from the start

When attempting to run karma tests after a clean install of the official Angular quickstart on Windows 10, I encountered an issue. Following a series of four commands, here is what happened: C:\projects\temp>git clone https://github.com/angul ...

Steps for creating a click event for text within an Ag-Grid cell

Is there a way to open a component when the user clicks on the text of a specific cell, like the Name column in this case? I've tried various Ag-Grid methods but couldn't find any that allow for a cell text click event. I know there is a method f ...

The Angular 2 view will remain unchanged until the user interacts with a different input box

I am currently working on implementing form validation using Reactive Forms in Angular 2. Here is the scenario: There are two input fields Here are image examples for step 1 and step 2: https://i.stack.imgur.com/nZlkk.png https://i.stack.imgur.com/jNIFj ...

Angular - Keeping component data in sync with service updates

Within my Angular application, I have several components utilized in an NgFor loop which all rely on a common service. My goal is to create a system where if one component alters a value within the shared service, that updated value will automatically pro ...

Bring in jspm libraries to your project via typescript

While researching how to import jspm packages into typescript, I noticed that most examples assumed the use of SystemJS for loading and interpreting them in the browser. However, I prefer using tsc to compile commonjs modules and only import the js code, a ...

Warning message in ReactJS Material UI Typescript when using withStyles

I am facing an issue even though I have applied styling as per my requirements: Warning: Failed prop type validation- Invalid prop classes with type function passed to WithStyles(App), expected type object. This warning is originating from Wi ...

What is the method for enabling imports from .ts files without file extensions?

While trying to open a Svelte project with TypeScript, I encountered an issue where all imports from .ts files were showing "Cannot resolve symbol" errors. https://i.stack.imgur.com/FCVxX.png The errors disappear when the .ts extension is added to the im ...

Access specific properties of an object in TypeScript using dot notation with the

Can we use dot notation to extract nested object elements in TypeScript? interface Test { customer: { email: string; name: { firstName: string; }; }; }; type PickedTest = ExtractNested<Test, "customer.name.firstName"> ...

What is the best way to connect a ref to a stateless component in React?

I need help creating a stateless component with an input element that can be validated by the parent component. In my code snippet below, I'm facing an issue where the input ref is not being assigned to the parent's private _emailAddress propert ...