https://github.com/epomatti/azure-docker-aspnetcore-app
App publishing to Azure Container Registry + Container Instances with Docker.
https://github.com/epomatti/azure-docker-aspnetcore-app
acr aspnetcore az-300 azure azure-container-instances azure-container-registry docker docker-image dotnet-core
Last synced: about 2 months ago
JSON representation
App publishing to Azure Container Registry + Container Instances with Docker.
- Host: GitHub
- URL: https://github.com/epomatti/azure-docker-aspnetcore-app
- Owner: epomatti
- License: mit
- Created: 2019-06-07T00:08:45.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2022-03-19T03:53:50.000Z (over 4 years ago)
- Last Synced: 2025-09-04T10:59:14.529Z (10 months ago)
- Topics: acr, aspnetcore, az-300, azure, azure-container-instances, azure-container-registry, docker, docker-image, dotnet-core
- Language: HTML
- Homepage:
- Size: 1.46 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Azure Docker app

A simple docker app that deploys a local Docker image to remote Azure Container Registry.

Requirements: .NET Core 6, Azure CLI, Docker
## Running locally
```bash
dotnet run
```
## Building your image
```bash
dotnet publish -c Release
docker build . --tag aspcontainers
```
To run your docker image locally:
```bash
docker run -d -p 5000:80 aspcontainers
```
## Publish to Azure
Steps to publish your built image to ACR and hosting on ACI.
Set the common environment variables (change values as you need):
```bash
# Create Azure Container Registry
export rg='rg-dotnetapp'
export acr='acrdotnetapp'
export aci='acidotnetapp'
export location='eastus'
```
Login to Azure, create the ACR and push the docker image:
```bash
# login to Azure from the CLI
az login
# create the resource group
az group create --name $rg --location $location --output Table
# create the container registry
az acr create --name $acr --resource-group $rg --sku Basic --output Table
# push to acr
az acr login --name $acr
docker tag aspcontainers "$acr.azurecr.io/aspcontainers"
docker push "$acr.azurecr.io/aspcontainers"
```
Get the and set it to a variable `export acrpass='<.....>'`
```bash
az acr update -n $acr --admin-enabled true
az acr credential show --name $acr --query "passwords[0].value"
```
Set the name for your container instance:
```bash
dns='yourappdns'
```
Finally, create your container instance:
```bash
az container create \
--resource-group $rg \
--name $aci \
--image "$acr.azurecr.io/aspcontainers:latest" \
--cpu 2 \
--memory 2 \
--registry-login-server "$acr.azurecr.io" \
--registry-username $acr \
--registry-password $acrpass \
--dns-name-label $dns \
--ports 80 \
--location $location
```
Your application should be available at http://yourappdns.eastus.azurecontainer.io.
To enable HTTPS for Container Instances in Production, [additional steps](https://docs.microsoft.com/en-us/azure/container-instances/container-instances-container-group-ssl) are required.

## Destroy the resources
Don't forget to clean your resources to avoid unwanted costs:
```bash
az group delete -n $rg
```