Skip to content

sunithapatel/cloud-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Workshop to Deploy to Azure with Azure App Service and SQL Azure

This is for the first two sessions in the Let Your Code Fly High! workshop series hosted in collaboration with Women Who Code Frontend & Cloud to showcase various ways to deploy a web application to the cloud.

Video Recordings

Sample Application Architecture

Tools for local development

Running the application on your local machine

It is possible to run the full application on your machine after you have installed the tools above and cloned this repository to your machine.

The commands below assume you are in the this folder (workshop-1-azure-app-service-and-sql-azure).

Initial set up of the database

Run SQL Server locally using Docker

If you have not pulled the Docker image for SQL Server, run the command below:

docker pull mcr.microsoft.com/mssql/server:2019-latest
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=YourStrong@Passw0rd' \
  -p 1433:1433 -h sq11 --name sql1 -v sqlvolume:/var/opt/mssql \
  -d mcr.microsoft.com/mssql/server:2019-latest

The connection string that points to this database server in the Docker container is in the appsettings.Development.json file in the api folder under ConnectionStrings.

Create database for the API

Once you have SQL Server database running locally, you can run the following command to execute the Entity Framework database migrations against the database to create the schema and populate data.

cd api
dotnet ef database update

This requires the install of Entity Framework CLI mentioned in the tools above.

Run the .NET API locally

cd api
dotnet run

Then navigate to http://localhost:7071/swagger in your browser to get to the Swagger page for the API dpcumentation.

Or instead, you can click F5 in Visual Studio Code to run with debugging that will build the project, run it and launch the browser for you. You can then debug and set breakpoints in the code.

By default the API is set up to connect to a local SQL Server database, so it will error if you run this before setting up your database. In Program.cs there is commented out code that you can use to connect to an in-memory database instead.

Run the React app locally

cd ui
npm start

Deployment to Azure

There are two services we can use in Azure to deploy the applications and the database.

  • The frontend React app and the backend .NET API can be hosted in Azure App Service.
  • The database can be hosted using Azure SQL - a managed service for SQL Server database in Azure

There are other ways to web applications like Azure Static Web Apps which will be covered later in a separate section.

Azure Deployment Diagram

Visual Studio Code has an Azure App Service extension we will use to do the deployments. Later we will see how to do this using a Continuous Integration & Deployment tool like GitHub Actions.

About

Workshop to learn to deploy web application to Azure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published