Creating an Azure App Service with a SQL Database using Node.js
Tags: react, azure, serverless, sql
Published: 2023-05-21 22:20:39

To create an app service with a SQL database in Azure, follow these steps:

1. Sign in to the Azure portal at https://portal.azure.com.

2. Click on the "Create a resource" button (+) in the Azure portal's left-hand menu.

3. In the search box, type "App Service" and select "App Services" from the suggested results.

4. Click on the "Create" button to begin creating a new app service.

5. In the "Basics" tab, configure the following settings:

- Subscription: Select the Azure subscription you want to use.
- Resource Group: Choose an existing resource group or create a new one to logically group related resources.
- Name: Enter a unique name for your app service.
- Publish: Choose the appropriate publishing method based on your application requirements (e.g., Code, Docker Container, etc.).
- Runtime stack: Select the runtime stack that matches your application (e.g., .NET, Node.js, Python, etc.). I chose Node.js because that is what I was using for my app service
- Operating System: Choose the operating system (Windows or Linux) for your app service.
- Region: Select the Azure region where you want to host your app service.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j724eu6xk4rrhfrj1fns.png)

6. Click on the "Next" button to proceed to the "Deployment" tab. Here, you give your Github repository and organisation name

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bznbsysrj77h8owk4vwm.png)

7. Click on the "Next" button to proceed to the "Networking" tab. Select "Enable public access" on so that others may access your website.

8. Click on the "Review + create" button to review your app service configuration..

9. After reviewing the settings, click on the "Create" button to create the app service. Azure will start provisioning the necessary resources for your app service.
Once the app service is created, navigate to the app service's Overview page.


## Creating a SQL Database

1. In the Overview page, click on the "Add" button under the "Settings" section and select "Azure SQL" from the dropdown menu.
 
2. In the "Add SQL connection" page, click on the "Create new database" option.
 
3. Configure the SQL database settings:
 

- Database name: Enter a name for your SQL database.
- Server: Choose an existing SQL server or create a new one.
- Pricing tier: Select the appropriate pricing tier based on your performance and cost requirements.
- Server admin login and password: Provide the login credentials for the SQL server.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p774pt45oj2di3bnypkb.png)

4. Click on the "OK" button to create the SQL database.

5. Once the database is created, you can access its connection string and other details from the app service's Overview page.

6. Update your application code or configuration to use the SQL database connection string obtained in the previous step.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7kys73rtkve38fj2fbs3.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/68m5tp7xf6l6brtmd084.png)

- On your Web App Service overview, select the domain link to view your website


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjurqloco651jsxf9d46.png)

Below is my domain link:
https://barbra.azurewebsites.net/

That's all! You have now created an app service in Azure using a SQL database. You can deploy your application code or content to the app service, which will connect to the corresponding SQL database for data storage and retrieval.