Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
416 stars 204 forks source link

Support deployment of containers to App Service #1608

Open pamelafox opened 1 year ago

pamelafox commented 1 year ago

I'd like to use AZD to deploy to Azure App Service BYOC, as shown in this article: https://foldr.uk/azure-bicep-app-service-custom-container

Should it be possible? It requires passing the image URL as the runtime version of the App Service app.

I've started down the path of creating a template, but want to check here before I bang my head against a wall too much.

weikanglim commented 1 year ago

@pamelafox

I'm guessing the deploy flow for App Service BYOC would look like:

  1. A dockerfile needs to be built, and uploaded to a container registry.
  2. After that, a bicep deployment needs to occur to update the linuxFxVersion to point to the latest image.

Unfortunately, azd makes an assumption that appservice hosts will work through zipdeploy by building and zipping the code artifact, which would be inconsistent with the deployment flow above. So I don't think targeting an appservice will work.

In many ways, the deployment flow is very, very close to containerapp targets. I suspect as a PoC (and as an informing decision to how azd could support it), you could use an existing azd project that targets a containerapp, and simply add the bicep definition for service plan + app service to the bicep module targeted by the containerapp service. This will end up deploying the container to both container app AND also app service, and you should see that the app service works as normal.

kurt-mueller-osumc commented 8 months ago

@weikanglim Could I do this for a function app where I bring my own container?

Similar to what you were describing, right now I build and push the function app image to a private azure container registry and then the function app detects the new image, pulls it, and deploys it as a container.

aaronpowell commented 5 months ago

I made a start on this last year but shifting priorities meant I wasn't able to get it through to completion. PR https://github.com/Azure/azure-dev/pull/2776 might be a good starting point for someone