.NET Core应用发布至Azure容器注册表后访问404问题求助
Hey Costas, great job getting your .NET Core MVC app containerized and pushed to Azure Container Registry (ACR)! The confusion here comes from a key difference between ACR and Azure App Service—let's clear this up and get your app running properly.
首先:ACR只是镜像仓库,不是运行服务
Azure Container Registry is just a place to store your Docker images (like Docker Hub), not a service that runs your application. That's why visiting https://costasdockertest.azurecr.io/ gives you a 404—there's no web server running there to serve your app. You need to deploy your ACR-hosted image to a service that can run containers, which will give you that familiar accessible URL like *.azurewebsites.net.
接下来的关键步骤:部署镜像到容器运行服务
Here are two common, straightforward ways to get your app up and running:
1. Deploy to Azure App Service (Web App for Containers)
This is the closest to the App Service experience you're used to:
- Head to the Azure Portal, create a new Web App resource.
- When setting up the app, under the Publish section, select Docker Container.
- Choose Azure Container Registry as the image source, then pick your registry (
costasdockertest.azurecr.io), your image, and the correct tag (usuallylatestfor release builds). - Finish creating the app—Azure will pull your image from ACR and start running it automatically.
- Once deployed, you can access your app via
http://<your-app-name>.azurewebsites.net. - Pro tip: If your .NET Core app listens on a port other than 80 (like 5000 by default in some older templates), add an app setting in App Service called
WEBSITES_PORTwith your port number to make sure traffic is routed correctly.
2. Deploy to Azure Container Instances (ACI)
This is a lighter, serverless option for quick testing:
- Use the Azure CLI (or Azure Portal) to create a container instance pointing to your ACR image. For example, with CLI:
az container create \ --resource-group <your-resource-group-name> \ --name costas-docker-test-aci \ --image costasdockertest.azurecr.io/<your-image-name>:latest \ --dns-name-label costas-docker-test-unique \ --ports 80 - Replace the placeholders with your actual resource group and image name. The
dns-name-labelneeds to be unique in your Azure region. - After deployment, your app will be accessible at
http://costas-docker-test-unique.<region>.azurecontainer.io.
Quick checks to avoid common issues
- Double-check your Dockerfile: Make sure it has the correct
ENTRYPOINTorCMDto start your .NET Core app (e.g.,ENTRYPOINT ["dotnet", "YourMvcApp.dll"]). - Confirm your local container runs correctly—if it works locally, the image itself is good, so the issue is almost always deployment-related.
- Verify you're using the release build of your image in ACR (sometimes debug builds can have different behavior or port settings).
Once you deploy to either App Service or ACI, your app should load just like it did locally. Let me know if you hit any snags along the way!
内容的提问来源于stack exchange,提问作者Costas Aletrari

