Coder Social home page Coder Social logo

helloaspnetcore-docker's Introduction

Sample ASP.NET Core 1.1 app for App Service on Linux

Sample docker image is at https://hub.docker.com/r/michimune/helloaspnetcore/

Overview

This is an example web application to learn the following three scenarios how to use App Service on Linux:

  1. Build a custom Docker image and deploy it to your web app with Azure CLI
  2. Enable CI/CD for the web app
  3. Use SSH session from Advanced Tools (aka Kudu)

Prerequisites

  1. Install Docker
  2. Install VS Code
  3. Install Azure Extension Pack and Docker extension to VS Code (https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-azureextensionpack)
  4. Make sure multi-factor authentication (MFA) works on your local machine

Build and Deploy a Custom Docker Image

  1. Clone the repository to your local machine.
  2. Open the project with VS Code.
  3. Build the project by typing Ctrl+Shift+P docker:build, choose Dockerfile.
  4. Publish the docker image by typing Ctrl+Shif+P docker:publish, and a tag (e.g. michimune/helloaspnetcore:latest).
  5. Launch Docker Azure CLI extension by typing Ctrl+Shift+P Docker:Azure CLI. This will launch a docker container with Azure CLI configured.
  6. Type az login. You will be prompted to navigate to http://aka.ms/devicelogin. Browse the page and copy and paste the code shown (~10 length characters) to the login page to complete the sign-in. When successful, you will see the list of subscriptions in your terminal.
  7. Create a web app: az webapp create --plan {AppServicePlanName} -g {ResourceGroupName} --name {SiteName}
  8. Set the docker container name to the web app: az webapp config set -g {ResourceGroupName} --linux-fx-version "DOCKER|michimune/helloaspnetcore:latest" --name {SiteName}
  9. Browse the site by launching http://{SiteName}.azurewebsites.net/.

Enable CI/CD

  1. In Azure CLI window, enable CI/CD: az webapp config appsettings set -g {ResourceGroupName} --settings DOCKER_ENABLE_CI=true --name {SiteName}
  2. Set deployment username and password (If needed): az webapp deployment user set --user-name {Username}
  3. Browse http://dockerhub.com and navigate to the repository.
  4. Choose Settings, add webhook:
  • Name: anything (e.g. docker)
  • Link: https://{Username}:{Password}@{SiteName}.scm.azurewebsites.net/docker/hook
  1. Update message.txt (For example, append one character) and save it.
  2. Type Ctrl+Shift+P docker:build, choose Dockerfile. Type or choose the same tag.
  3. Type Ctrl+Shift+P docker:publish, choose the same tag.
  4. Wait for a while and refresh the page to confirm that the text is updated.

SSH

  1. Log in to the Azure portal at https://portal.azure.com/. Navigate to App Services and choose the web app that was created during the above scenario.
  2. Choose Advanced Tools, and click Go. A new Kudu session is opened.
  3. Choose Debug console followed by SSH.
  4. Type apt-get install vim -y to install vim.
  5. Type vi message.txt, edit the contents (e.g. append ! by typing A!<ESC>) and type ZZ to save and exit.
  6. Refresh the page.

helloaspnetcore-docker's People

Contributors

michimune avatar

Watchers

 avatar  avatar

Forkers

apurvajo

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.