Coder Social home page Coder Social logo

docker-azure-aspnet's Introduction

Docker Containers in Azure

How to containerise and deploy an ASP.Net web app to Azure!

Prerequisites

  • Install Docker Desktop
  • Install VSCode
  • Install the .Net 6 SDK

From Azure

  • Create a new resource group
  • Create a new container instance inside that resource group
  • Create a new container registry (this is where you will push/save your Docker image of the ASP.Net web app to)

From VSCode

  • Install the Azure extension
  • Connect to your Azure account
  • Install the Docker extension
  • In the Docker extension bit
    • you should see all the Docker images and containers you currently have on your machine in a list
    • you should also see a part for Azure which shows the container registry you've just made

Create a Dockerfile

  • Ensure you are pulling the Docker images for ASP.Net and the .Net SDK for the version of .Net you're using. In this case, .Net 6
  • If you don't include the image for the .Net SDK, you will get errors at the dotnet restore or other .Net CLI command steps in the Dockerfile because it needs to have .Net installed in the Docker environment in order to run the CLI commands

Build your Docker image from the Dockerfile and push to your Azure container registry

  • Open a VSCode integrated Terminal and show the 'Output' tab
  • Right click on the Dockerfile in VSCode and among the options you'll see 'Build image in Azure'
  • Click on that and, in the prompt at the top of the screen ('Tag image as...'), select the name matching your project.
  • Then in the next prompt for a container registy for it to live in, select the container registry you made earlier in Azure
  • The Output tab of the VSCode Terminal will show:
    • Docker building the container image from your instructions in the Dockerfile
    • Docker pushing the newly built image to your specified Azure container registry

Deploy your ASP.Net app to a container instance from the pushed container image

  • In Azure, create a new resource > Containers > Container Instances
  • Azure container registry
  • Select the container registry you made earlier
  • It should autopopulate the next bit with the container image you've just pushed to the registry
  • Make sure u got da free plan :money:
  • Create! Now you can navigate to the url of the newly created resource and your ASP.Net app is out there ๐Ÿš€

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.