This repository contains steps to deploy a simple web application, running the SQL database and Azure Blob storage on Azure Cloud Platform. Follow the following steps to run this app on the machine, with database and on the Azure Cloud Platform. This app can be run on local and virtual machine. However, steps to run this app on a Azure virtual machine and creating that machine are not covered in this repository.
Here are some of the requirements, to run these scripts on your local machine:
- Download a text editor like Microsoft Visual Studio Code. Link to download Microsoft Visual Studio Code: https://code.visualstudio.com/
- Set up a Microsoft Azure account. Here's link to create your Azure account: https://azure.microsoft.com/en-gb/
- Set Azure Command Line Interface on your device. Download Azure CLI tool using the link: https://docs.microsoft.com/en-us/cli/azure/
- Use the following command in your command prompt or terminal of your VS Code to log-in to your Azure account.
$ az login
- Download latest version of Python from the link: https://www.python.org/downloads/
Run this script on your command prompt or terminal of your VS Code to create a resource group:
$ az group create -l westus -n resource-group-west
Here are steps to create the SQL Server and Database, on Microsoft Azure:
-
Run this script on your command prompt or terminal of your VS Code to create the SQL server:
$ az sql server create --admin-user uadmin --admin-password p@ssword1234 --name hello-world-server --resource-group resource-group-west --location westus2 --enable-public-network true --verbose
-
Run this scripts on your command prompt or terminal of your VS Code to create outbound firewall rule for your SQL server:
$ az sql server firewall-rule create -g resource-group-west -s hello-world-server -n azureaccess --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0 --verbose
-
Now, determine the IP of your computer, and copy that to add that in step 4. You can determine your IP by running the following command: For windows command prompt:
$ ipconfig /all
For mac:$ curl ifconfig.me
-
Now, add your IP address into the following command, to create a firewall rule to connect to your SQL server:
$ az sql server firewall-rule create -g resource-group-west -s hello-world-server -n azureaccess --start-ip-address [ADD YOUR IP ADDRESS] --end-ip-address [ADD YOUR IP ADDRESS] --verbose
-
Now, execute following command to create the Database in your SQL server:
$ az sql db create --name hello-world-db --resource-group resource-group-west --server hello-world-server --tier Basic --verbose
Here are steps to create he Azure Blob storage on Microsoft Azure. This will store all the images of the web app.
-
Execute following command to create a storage account for your blob storage:
$ az storage account create --name helloworld12345 --resource-group resource-group-west --location westus2
-
Now, we need to add a Blob Container. For this, you will need to access your Azure Account from online portal. And search about Azure Storage Accounts. And follow the steps accordingly: a. Once the Storage account is deployed, click on its name to access it (you may need to go back to the main "Storage accounts" page in Azure). b. Click on the "Containers" button in the storage account's "Overview" page. c. Click "+ Container", then add the name of images. d. Set "Public access level" to Container, and click "Create".
For running the application, you will need to copy following information of your resources, from your Azure Portal. Then update this information into some of the files, and then run the application.
- To connect an app to the storage we've set up, we need a few things from each storage service. From the SQL server and database: SQL Server server name (the name of the sql server with .database.windows.net appended to it), Admin username, Admin password ,SQL Database name. From blob storage: Storage account name, A storage account access key (From the Azure portal, navigate to the storage account, and then under "Setting", click on "Access keys". Copy and paste the "Key" under "key1", including the double equal signs ("==") at the end), Container name.
- Now, within config.py, update all the values, that we noted down in previous steps.
- Now, setup the terminal, go to the directory of the application, and run the application.py file