Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 2.89 KB

Challenge-02.md

File metadata and controls

40 lines (27 loc) · 2.89 KB

Challenge 02 - Move to Azure SQL Database

< Previous Challenge - Home - Next Challenge >

Introduction

So far we have deployed a SQL Server on Linux containers which was really convenient for dev/test scenarios, especially locally. But now with this challenge we would like to leverage Azure SQL Database as a Platform-as-a-Service (PaaS) which offers out-of-the-box features for Production: security patching, SQL Server upgrades, auto-tuning, geo-replication, scaling up or down the size of the server, etc. that we don't want to do by ourselves.

Move to Azure SQL Database

Description

  • Provision your Azure SQL Database via Infrastructure-as-Code (you can use the Azure Cloud Shell if you don't have the tools installed locally). The approach here is to leverage an Infrastructure-as-Code language like Azure CLI/Bicep/PowerShell/Terraform/etc (not the Azure portal). Friends don't let friends use the UI to provision Azure services, right? ;)
  • Update your app (re-build and re-deploy the Docker image) with the new connection string (as an environment variable), test the app as an end-user and play a game once deployed there.

Success Criteria

To complete this challenge successfully, you should be able to:

  • Validate that you have an Azure SQL Database deployed & running
    • Make sure az sql server list and az sql db list are showing your Azure services properly.
  • In your web browser, navigate to the app and play a game, make sure it's still working without any error and that it is using the Azure SQL Database as its backend datastore.

Learning Resources

Tips

  • You can get the Azure SQL Database connection string by several different ways
    • Azure CLI: az sql db show-connection-string -s <sql-server-name> -n <sql-db-name> -c ado.net
    • Azure Portal: Go to the Azure SQL Database resource, click on Show database connection strings and copy the ADO.NET (SQL Authentication) connection string
  • Add SQL IP firewall rules to restrict access to just your local IP & Azure trusted services
  • Use docker compose up --build --remove-orphans to re-build & re-deploy the Docker images locally
    • The --remove-orphans flag removes the old SQL Server image you used in the previous challenge