-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Issue] Figure out flow for custom domain names #1765
Comments
Not sure if it helps, but I usually think of setting up DNS for an application as two separate steps:
I don't think you'd want to set up DNS immediately as part of the app provisioning, until you have everything confirmed working. |
We need to provide some guidance around this before GA. |
@weikanglim @pamelafox is there any existing Azure documentation which already exists which we can point to as part of Azd FAQ? |
I managed to setup a custom domain via Bicep for an ACA template but it's not perfect and it's also a bit of a chicken and an egg problem. I have my certificate as a managed certificate in the Container App Environment (added after first provision). Then I just use the certificateId as part of the So at the end of the day, the UX flow for someone consuming this template would be:
|
It may be possible to do a slightly nicer workflow by using conditions in the Bicep? i.e. customDomain is in parameters.json, only create the resources in the Bicep if customDomain is !empty. Or is there a reason commenting out is necessary vs. Bicep conditionals? |
I'm no Bicep expert so perhaps a conditional statement will suffice! I will investigate this a bit further and circle back! |
I'd love for the flow to look sequential:
But if we find the single IaC easier to reason about, that'd be fine too. From an advanced IaC authoring perspective, creating bicep conditionals based on Azure state may make it harder to test and maintain over time. |
At the moment to do this, I have to use 'azd infra synth'. In the containerApp.tmpl.yaml files for my web projects I add lines for custom domain under 'ingress':
I then add those environment variables as input and output in main.bicep and main.parameters.json so they can be fed by variables in my CI/CD environment. To deploy, I need to do the 'azd provision' step first. Once the container app environment is up, I can manually upload my cert and configure DNS as required. Then azd deploy after that. (My cert and domain aren't Azure managed at the moment but that's the direction I'd like to go eventually.) If I don't put those lines in the yaml, the SSL cert binding gets removed by azd deploy, so it's the only way I've found so far that I can deploy with this can keep the custom domain in place. It would be great if in Aspire you could specify that a project will have a custom domain, something like: pseudocode:
If 'userProvidedCertificate' is true: If 'userProvidedCertificate' is false: I'd love to get away from needing 'azd infra synth' so that everything is driven by code from my aspire project and this is one of the main puzzle pieces preventing that at the moment for me. |
The medium-term plan (post the initial aspire GA, but high priority after that) is to provide a way to allow full customization of the |
@ellismg That's great to know the vision and this pain point will go away, thanks for sharing that. That'll really simplify things, looking forward to it. |
This is a blocker for us for adapting aspire. |
@mip1983 how did you manage customDomains to work? I added the same to my service yaml file inside ingress settings, but azd deply seems to ignore this lines and drops network settings again and again. So annoying |
There's now a command in azd to get it to preserve your domain settings:
So in my build pipeline (Azure DevOps):
The domain and cert are manually set up in the Azure portal after deploy, but this command ensures they're preserved. I'm using an externally managed domain and certificate at the moment, eventually would like this to all be azure managed and generated via aspire. |
I use GutHub actions for deployment. I added a stet with this setting but nothing has changed.
Does anyone know what is wrong here? I did the same locally from the dev machine and used "azd up" and it seem to take the customDomain section but it end up with error "Invalid certificateId". @mip1983 please, can you tell me what is this certificate Id? I use azure managed certificated and in the portal I see only certificate names. I tried to use them but no luck |
@relounge If you're using 'azd config set alpha.aca.persistDomains on' you can remove the custom domains bit from your YAML file. That's only something I used along with output variables from bicep before this alpha.aca.persistDomains existed as a work around to stop it clearing the domain config each time. Unless you're doing any other customization, you can just take the YAML that infra synth generates (or not use it at all if this is your only customization) along with this azd config command. |
Thanks it worked. Added this to my workflow file.
The only one thing left is to understand how to stop dropping ingress settings all the time, I mean allow an endpoint to be external after deployment. But this is out of this topic |
Hopefully should be a simple one liner 'WithExternalHttpEndpoints' in Program.cs of your Aspire.AppHost project e.g.: var webApp = builder.AddProject<Projects.web>("<your-web-project>")
.WithExternalHttpEndpoints(); |
Is there any guidance in the works for this area? Would be good to switch over to an aspire/azure based dns and certificate solution |
We are just about to backport a change into release/9.0 of Aspire to allow custom domains to be set when using |
Output from
azd version
azd version 0.7.0-beta.1 (commit 9ce7165)
Describe the bug
Everything is working as currently designed, so this is more a bug in the process than the code.
I would like to be able to use azd to deploy a website that has a custom domain attached (on Static Web Apps, App Service, or Container Apps). However, if I specify a domain name in Bicep using 'Microsoft.Web/staticSites/customDomains@2022-03-01' that has not yet been verified, then I get an error during the provision stage. I cannot verify a domain name until I know the website endpoint, however, since the DNS record is a CNAME for 'www' with the value of the website endpoint.
This is how I ended up doing it for my personal website, www.pamelafox.org:
https://github.com/pamelafox/pamelafox-site/blob/main/infra/swa.bicep#L24
azd up
with domainName still empty in main.parameters.jsonand wait a few minutes
That seemed to work, but it's possible that I also intervened in the Portal in between those steps.
Maybe there'd be a more straightforward approach if I used Azure's registrar? I already have a registrar I pay for, so I set it up there.
The text was updated successfully, but these errors were encountered: