azure sql database Archives - Learn Smart Coding https://blogs.learnsmartcoding.com/tag/azure-sql-database/ Everyone can code! Sat, 11 Jan 2020 01:15:52 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.1 209870635 Configure elastic pools for Azure SQL Databases https://blogs.learnsmartcoding.com/2020/01/11/configure-elastic-pools-for-azure-sql-databases/ https://blogs.learnsmartcoding.com/2020/01/11/configure-elastic-pools-for-azure-sql-databases/#respond Sat, 11 Jan 2020 01:15:52 +0000 https://karthiktechblog.com/?p=315 Introduction This post, I show how to configure elastic pools for Azure SQL Database. Microsoft Azure SQL Database are great for both predictable and unpredictable workloads. Unpredictability is specially challenging for software as service or called as SaaS Providers. SaaS providers have hundreds or even thousands of customers who then have their own unique mix […]

The post Configure elastic pools for Azure SQL Databases appeared first on Learn Smart Coding.

]]>
Introduction

This post, I show how to configure elastic pools for Azure SQL Database. Microsoft Azure SQL Database are great for both predictable and unpredictable workloads.

Unpredictability is specially challenging for software as service or called as SaaS Providers. SaaS providers have hundreds or even thousands of customers who then have their own unique mix of performance demands.

A common output is found that SaaS providers over provision their databases to meet variable and peak demands(resource demands) which is not cost effective and brings in management issues.

To solve this and operate cost effective, a predictable cost can be found by using elastic pool databases.

What are SQL elastic pools

SQL Database elastic pools are a simple, cost-effective solution for managing and scaling multiple databases that have varying and unpredictable usage demands.

Elastic pools help solve this problem by enabling you to set a policy for a group of elastic database ensuring that databases get the performance resources they need when they need it.

They provide a simple resource allocation mechanism within a predictable budget.

You don’t need to worry about each database or over provisioning for peak demands.

To check price for various service tier, visit Explore all SQL Database pricing options

Configure elastic pools for Azure SQL Database

Within the database server blade, you can see I have many databases. simply click on Add Pool.

Configure elastic pools for Azure SQL Databases
providing name for elastic pool

Next is to give it a name. Provide name to the pool .

To choose different elastic pool configuration, click on ConfigurePool option as shown in the above image.

Configure elastic pools for Azure SQL Databases

There are many Service Tier available and the pricing differ for each one. Once you chose the right options, click on Databases.

Choose database for elastic pool

Click on the Plus symbol to see the available databases. Choose the databases from the right side menu.

choosing service tier and configure elastic pool

Next option is to choose “PerDatabase” configuration and click on Apply.

Right side you can see the pricing shown per month. Likewise, you can see pricing for different option that you may choose.

Now you will see “Your deployment is underway” message, please be patience and give few minutes time for the process to complete.

Important to note:

There is no per-database charge for elastic pools. You will be billed for each hour a pool exists at the highest eDTU or vCores, regardless of usage or whether the pool was active for less than an hour.

When should you consider a SQL Database elastic pool

Pools are well suited for a very large number of databases with specific utilization patterns. The more databases you can add to a pool the greater your savings become.

Conclusion

In this post, I showed how to configure elastic pools for Azure SQL Database. The details in this post will help to cover a part of knowledge required to complete Azure AZ-203 certification.

That’s all from this post. If you have any questions or just want to chat with me, feel free to leave a comment below.

The post Configure elastic pools for Azure SQL Databases appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2020/01/11/configure-elastic-pools-for-azure-sql-databases/feed/ 0 315
Configure Azure SQL relational database using vs 2019 https://blogs.learnsmartcoding.com/2019/10/19/configure-azure-sql-database-and-migrate-changes-using-dotnet-cli/ https://blogs.learnsmartcoding.com/2019/10/19/configure-azure-sql-database-and-migrate-changes-using-dotnet-cli/#respond Sat, 19 Oct 2019 12:49:25 +0000 https://karthiktechblog.com/?p=226 Introduction In this post, we will see how to configure the Azure SQL database using vs 2019. This post is a continuation of how to provision a relational database. To read more about how to provision the relational database in the Azure portal, take a look at my post provision and configure relational databases azure […]

The post Configure Azure SQL relational database using vs 2019 appeared first on Learn Smart Coding.

]]>
Introduction

In this post, we will see how to configure the Azure SQL database using vs 2019. This post is a continuation of how to provision a relational database.

To read more about how to provision the relational database in the Azure portal, take a look at my post provision and configure relational databases azure portal

Demo Application Overview

In this demo, we will see how to create a small shopping API application by designing its database schema with minimum tables required for demo.

Once we design our database, we will see how to migrate these changes to the Azure SQL database using DOTNET CLI.

This demo application is created using Visual Studio 2019 and in DOTNET CORE 2.2

In my previous post, I have explained how to provision relational databases in the Azure portal. You may read the post to set up the new SQL database in the Azure portal.

Application Architecture

I have created this application with standard architecture addressing the separation of concerns. We have the following layers in our application.

  • API (Main project)
  • CORE
  • CrossCutting
  • Service
  • Data

The full demo application is available for free and you may download from my GitHub repository.

Database schema to configure Azure SQL database

We have three tables namely Category, Product and ProductImages. Each product will be under a Category and each product might have more than one image to show.

Based on this we will start our relationship in our model. All the entities will go to the Core project.

using System.ComponentModel.DataAnnotations;

namespace KarthikTechBlog.Shopping.Core
{
    public class Category
    {
        public int Id { get; set; }
        [Required]
        [MinLength(2), MaxLength(200)]
        public string Name { get; set; }
        public Status Status { get; set; }
    }
}

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace KarthikTechBlog.Shopping.Core
{
	public enum Status
    {
        InActive = 0,
        Active = 1,
        Suspended = 2
    }
	
    public class Product
    {
        public int Id { get; set; }
        [Required]
        [MinLength(5), MaxLength(200)]
        public string Name { get; set; }
        public decimal Price { get; set; }
        public DateTime? AvailableSince { get; set; }
        public int StockCount { get; set; }
        public int CategoryId { get; set; }
        public Category Category { get; set; }
        public List ProductImages { get; set; }
        public Status Status { get; set; }

    }
}

using System.ComponentModel.DataAnnotations;

namespace KarthikTechBlog.Shopping.Core
{
    public class ProductImages
    {
        public int Id { get; set; }
        [Required]
        [MinLength(128), MaxLength(128)]
        public string ImageId { get; set; }
        public int ProductId { get; set; }
        public Product Product { get; set; }
        public Status Status { get; set; }
    }
}

To follow along with me, download or clone the demo application from the GitHub URL .

Database Migrations

Open the project folder “KarthikTechBlog.Shopping.Data” using the command line.

I’m going to show how to generate a migration script and update the database using DOTNET CLI.

dotnet ef migrations add initalcreate -s ../KarthikTechBlog.Shopping.API/KarthikTechBlog.Shopping.API.csproj

In this, we are creating a migration script named “initialcreate” and specifying our startup project by specifying “-s project-path“. Once you create migration using the above command, you can see the migration folder added to your project.

dotnet ef database update -s ../KarthikTechBlog.Shopping.API/KarthikTechBlog.Shopping.API.csproj

To push the created migration script to our database, run the above command.

Conclusion

In this post, you learned how to configure relational databases with azure SQL database using Visual Studio 2019 and DOTNET CLI.

That’s all from this post. If you have any questions or just want to chat with me, feel free to leave a comment below. If you want to get a continuous update about my blog, make sure to follow me on Facebook and Twitter.

The post Configure Azure SQL relational database using vs 2019 appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2019/10/19/configure-azure-sql-database-and-migrate-changes-using-dotnet-cli/feed/ 0 226
Provision and Configure relational databases in azure portal: part 1 https://blogs.learnsmartcoding.com/2019/10/14/provision-and-configure-relational-databases-azure-portal/ https://blogs.learnsmartcoding.com/2019/10/14/provision-and-configure-relational-databases-azure-portal/#respond Mon, 14 Oct 2019 01:53:36 +0000 https://karthiktechblog.com/?p=206 Introduction This post is to provision and configure relational databases in the azure portal and is part of develop solutions that use a relational database. This post is part of the Azure AZ-203 certification path. The topic covered in this post is part of skills measurement, “Develop for Azure storage” and about 15-20 % of […]

The post Provision and Configure relational databases in azure portal: part 1 appeared first on Learn Smart Coding.

]]>
Introduction

This post is to provision and configure relational databases in the azure portal and is part of develop solutions that use a relational database.

This post is part of the Azure AZ-203 certification path. The topic covered in this post is part of skills measurement, “Develop for Azure storage” and about 15-20 % of skills are measured.

There are four topics under this skill measurement as shown below.

  • Develop solutions use
    1. storage tables
    2. Cosmos DB storage
    3. a relational database
    4. blob storage

Develop solutions that use a relational database

  1. provision and configure relational databases
  2. configure elastic pools for Azure SQL Database
  3. create, read, update, and delete data tables by using code
  4. provision and configure Azure SQL Database serverless instances
  5. provision and configure Azure SQL and Azure PostgreSQL Hyperscale instances

In this post, I will cover point # 1, how to provision and configure relational database using Azure SQL Server.

Before we get started, see take a look at Prerequisite below.

Prerequisite

  1. You need an Azure subscription. If you don’t have an account, you may create at “https://azure.microsoft.com/en-us/free/“. It is free and includes $200 to explore any Azure service for 30 days.
  2. Basic knowledge of the relational database.
  3. Visual Studio 2019 or 2017

Let’s get started..

Provision and configure relational databases

Once you have “Signed In” to the Azure portal, you will be able to see a bunch of links to the left side of the screen, refer below image. If you are yet to sign in, follow this link to sign in http://portal.azure.com.

Choosing SQL Database

Click in SQL Databases to the left side menu.

provision and configure relational databases

Click on “+ Add” to the top center of the screen as shown in the image. I have my SQL instance running so it is showing up in the available list.

add new database

Configuring SQL Server and SQL Database

Now, we need to provide some information to create a SQL Server and SQL database.

  • Choose subscription details from the drop-down, if you ave created your new account then you will see subscription as “Free Trail”.
  • Next is to create a resource group. Hey wait wait…, what is the resource group?

According to Microsoft, a resource group is described below.

resource group – A container that holds related resources for an Azure solution. The resource group includes those resources that you want to manage as a group. You decide which resources belong in a resource group based on what makes the most sense for your organization

From Microsoft

For more information, visit https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-overview

provision and configure relational databases

Create a new SQL server

We should create a new SQL server and provide a unique name to our database. Click on “Create New“, there will be a popup shown to your right side. Fill up the server name, provide username and password, choose a location.

I have created a database name “shopping“. I will cover how to configure this database and execute migration scripts using visual studio 2019.

configure SQL Database and choose SQL server

Click on “Review + Create” and you are done. It takes a few seconds to deploy the server.

list of SQL database

To check the connection string of the SQL server and database that we created, go to “SQL Databases” link in the left menu. You can then choose your newly created database and go to the Overview blade (menu).

overview blade of SQL server and database

To your top right side, click on “show database connection string” to copy the connection string.

Note:

Azure database is secured by default, meaning no external connections will be accepted by the firewall. In order to connect to your Azure database from your local, you need to add your IP (client IP) in the SQL Server in the Azure portal.

Read my post on how to SET UP CI PIPELINE FOR ANGULAR APPLICATION USING AZURE DEVOPS BUILD to learn azure DevOps pipeline.

Conclusion

In this post, you learned how to provision and configure relational databases in the Azure portal. In my next post, I will show how to design a database schema for a small application and push the changes to our SQL Database in Azure.

That’s all from this post. If you have any questions or just want to chat with me, feel free to leave a comment below. If you want to get a continuous update about my blog, make sure to follow me on Facebook and Twitter.

The post Provision and Configure relational databases in azure portal: part 1 appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2019/10/14/provision-and-configure-relational-databases-azure-portal/feed/ 0 206