sparse-intern-71089
06/05/2023, 3:47 PMclever-sunset-76585
06/05/2023, 5:11 PMTXT
verification record using the verification ID property of the Container Apps environment once it's created. The second flag is used to set the DNS suffix property of the Container Apps environment knowing that the TXT
record has been added already.
Unfortunately, it's a pattern I've found myself employing with a few Azure services when trying to bind a custom domain to them. For instance, API management service and App Service are the other two services where I've had to do this.
The problem is that it seems the Azure APIs have validations, as you might have encountered, that only the Azure Portal can honor because of the manual intervention.clever-sunset-76585
06/05/2023, 5:15 PMuseCustomDomains
needs to be set first before setContainerAppsDnsSuffix
can bet set to true
for any fresh stack. As you might already know this is a problem with fresh stack deployments. Once a stack is Container Apps environment is fully provisioned, you don't need to touch those stack config properties again for that stack.
if (!stackConfig.useCustomDomains && stackConfig.setContainerAppsDnsSuffix) {
throw new Error(
"Cannot set the DNS suffix cannot for the Container App Environment without also setting useCustomDomains."
);
}
if (stackConfig.setContainerAppsDnsSuffix) {
if (!stackConfig.containerAppsCertificate) {
throw new Error(
"containerAppsCertificate stack config is required when using custom domains"
);
}
customDomainConfiguration = {
dnsSuffix: hostedZoneName,
certificateValue: stackConfig.containerAppsCertificate.apply((c) =>
Buffer.from(c, "utf-8").toString("base64")
),
certificatePassword: stackConfig.containerAppsCertificatePassword,
};
}
// The external container apps environment is publicly accessible
// from the internet.
export const externalContainerAppsEnvironment =
new containerApps.v20221001.ManagedEnvironment("externalContainerAppsEnv", {
resourceGroupName: resourceGroup.name,
appLogsConfiguration: {
destination: "log-analytics",
logAnalyticsConfiguration: {
customerId: logAnalyticsWorkspace.customerId,
sharedKey: logAnalyticsWorkspaceSharedKeys.apply(
(k) => k.primarySharedKey!
),
},
},
vnetConfiguration: {
infrastructureSubnetId: containerAppsInfraSubnet.id,
internal: false,
},
customDomainConfiguration,
tags: getDefaultTags(),
});
if (stackConfig.useCustomDomains) {
if (!hostedZoneId) {
throw new Error("hostedZoneId is required");
}
// Add the verification and the CNAME records to the Cloudflare zone.
const txtVerificationRecord = new cloudflare.Record(
"txtVerificationRecord",
{
name: `asuid.${hostedZoneName}`,
type: "TXT",
zoneId: hostedZoneId,
value: externalContainerAppsEnvironment.customDomainConfiguration.apply(
(v) => v!.customDomainVerificationId!
),
// 1 is a special value here meaning "automatic".
ttl: 1,
}
);
}
glamorous-waitress-51149
06/05/2023, 7:22 PMglamorous-waitress-51149
06/05/2023, 7:30 PMglamorous-waitress-51149
06/05/2023, 7:30 PMfast-vr-6049
06/05/2023, 7:54 PMglamorous-waitress-51149
06/05/2023, 7:56 PMclever-sunset-76585
06/05/2023, 10:03 PMglamorous-waitress-51149
06/06/2023, 7:10 AMazure-native:app:ContainerApp (webhooks-cnx): error: Code="InvalidCustomHostNameValidation" Message="A TXT record pointing from asuid.foo-webhooks.blah.tech to 9A101... was not found."
clever-sunset-76585
06/06/2023, 5:43 PMTXT
record has the container app's name in it, so it's unique per container app. You'll have to ensure that the TXT
record gets created before you set the custom domain settings in the ingress object of the container app. What does your TXT
record resource look like? I have a hunch you might be depending on the verification ID from the container app which is introducing a circular dependency.glamorous-waitress-51149
06/06/2023, 5:47 PMclever-sunset-76585
06/06/2023, 5:53 PMbored-activity-40468
06/08/2023, 2:54 PMbored-activity-40468
06/08/2023, 2:57 PMclever-sunset-76585
06/08/2023, 3:22 PMglamorous-waitress-51149
06/08/2023, 3:23 PMbored-activity-40468
07/02/2023, 6:05 PMclever-sunset-76585
07/02/2023, 6:13 PMbored-activity-40468
09/13/2023, 1:27 AMclever-sunset-76585
09/13/2023, 1:44 AMlittle-library-54601
09/20/2023, 8:46 PMlittle-library-54601
10/18/2023, 9:01 PMbored-activity-40468
10/19/2023, 1:48 AM