Skip to content

Instantly share code, notes, and snippets.

@tonkatsu7
Last active July 1, 2019 14:22
Show Gist options
  • Save tonkatsu7/9e0cc3bee6e2bc9bcbc5f976cff907cc to your computer and use it in GitHub Desktop.
Save tonkatsu7/9e0cc3bee6e2bc9bcbc5f976cff907cc to your computer and use it in GitHub Desktop.
Notes from eShoppOnWeb ASP.NET Core on Azure reference application tutorial https://github.com/dotnet-architecture/eShopOnWeb

Git repo

https://github.com/dotnet-architecture/eShopOnWeb

Author website

https://ardalis.com/

Book

https://docs.microsoft.com/en-us/dotnet/standard/modern-web-apps-azure-architecture/

Pre-requisites

https://github.com/dotnet-architecture/eShopOnWeb/wiki/Getting-Started-for-Beginners

Intalling VS2019

Select the following workloads/individual components:

  1. ASP.NET and web development
  2. .NET cross platofrm development
  3. .NET Core 2.2

Step 2: Create your first ASP.NET Core web app

https://docs.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-aspnet-core-ef-step-02?view=vs-2019

Step 3: Work with data using Entity Framework

https://docs.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-aspnet-core-ef-step-03?view=vs-2019

Note the following deviations:

  1. Add code to Program.cs to create database:

  2. Import statements using Microsoft.Extensions.DependencyInjection; using WebApplication1.Models;

  3. Change var context = services.GetRequiredService<SchoolContext>(); should be var context = services.GetRequiredService<AppDbContext>();

Step 4: Expose a web API from your ASP.NET Core app

https://docs.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-aspnet-core-ef-step-04?view=vs-2019

Note the following deviations:

  1. Add an API controller

  2. Choose the model class WebApplication1.Models.Game

Step 5: Deploy your ASP.NET Core app to Azure

  1. Publish

  2. Create New

1. Add a SQL Server

  1. Create
  
    1. Connection String Name = DefaultConnection
  1. Update connection string

  2. In addition to changing the connection string name in appsettgins.json, also change in Startup.cs

Setting up your dev environment

CLone repo

git clone https://github.com/dotnet-architecture/eShopOnWeb.git

Open in VS2019 for latest Docker support

devenv eShopOnWeb\eShopOnWeb.sln

Run locally from VS2019 using Linux containers

https://github.com/dotnet-architecture/eShopOnWeb/wiki/03.-Running-Locally-on-a-Linux-Container-from-Visual-Studio

Note the following deviations:

  1. As a pre-requisitem enable shared drives in Docker Desktop > Settings > Shared Drives and enable the drive containing the project source
  2. When following steps 3 and 4, selecting Web project > Add > Docker Support will not create a new project called docker-compopse, instead it will:
  3. create a new Web\Dockerfile, and
  4. backup the old one to Web\Dockerfile.original
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment