Azure SQL Hyperscale Revealed: High-Performance Scalable Solutions For Critical Data Workloads
Azure SQL Hyperscale Revealed: High-Performance Scalable Solutions For Critical Data Workloads
Hyperscale
Revealed
High-performance Scalable Solutions
for Critical Data Workloads
—
Zoran Barać
Daniel Scott-Raynsford
Azure SQL Hyperscale
Revealed
High-performance Scalable Solutions
for Critical Data Workloads
Zoran Barać
Daniel Scott-Raynsford
Azure SQL Hyperscale Revealed: High-performance Scalable Solutions for Critical
Data Workloads
Zoran Barać Daniel Scott-Raynsford
Resolution Drive, Auckland, 0930, New Zealand Victory Road, Auckland, 0604, New Zealand
Introduction�������������������������������������������������������������������������������������������������������������xv
Part I: Architecture����������������������������������������������������������������������������������������� 1
Chapter 1: The Journey to Hyperscale Architecture in Azure SQL��������������������������� 3
SQL on Azure��������������������������������������������������������������������������������������������������������������������������������� 5
The Basics of Azure SQL���������������������������������������������������������������������������������������������������������� 5
Azure SQL Platform as a Service�������������������������������������������������������������������������������������������������� 7
Deployment Models����������������������������������������������������������������������������������������������������������������� 9
Purchasing Models and Service Tiers����������������������������������������������������������������������������������� 10
Availability Models and Redundancy������������������������������������������������������������������������������������� 13
Standard Availability Model: Locally Redundant Availability�������������������������������������������������� 15
General Purpose Service Tier: Zone-Redundant Availability�������������������������������������������������� 16
Premium and Business Critical Service Tier: Locally Redundant Availability������������������������ 18
Premium and Business Critical Service Tier: Zone-Redundant Availability��������������������������� 19
Protecting Against Regional Outages Using Failover Groups with
Geo-redundant Availability���������������������������������������������������������������������������������������������������� 21
The Hyperscale Service Tier������������������������������������������������������������������������������������������������������� 22
Hyperscale Architecture Overview���������������������������������������������������������������������������������������� 24
Deploying Your First Hyperscale Database���������������������������������������������������������������������������� 25
Cleaning Up��������������������������������������������������������������������������������������������������������������������������� 34
Summary������������������������������������������������������������������������������������������������������������������������������������ 35
iii
Table of Contents
iv
Table of Contents
Deploying the Starting Environment Using the Azure Cloud Shell��������������������������������������� 133
Creating a SQL Administrators Group���������������������������������������������������������������������������������� 136
Deploying a Highly Available Hyperscale Database into a Virtual Network������������������������������� 139
Basic Configuration of the Database����������������������������������������������������������������������������������� 141
Configuring Network Connectivity��������������������������������������������������������������������������������������� 146
The Final Configuration Tasks and Deployment������������������������������������������������������������������� 150
Deleting the Example Environment������������������������������������������������������������������������������������������� 155
Summary���������������������������������������������������������������������������������������������������������������������������������� 157
Chapter 6: Configuring Transparent Data Encryption to Bring Your Own Key������ 171
Enabling Customer-Managed Key Transparent Data Encryption����������������������������������������������� 172
Creating a User-Assigned Managed Identity����������������������������������������������������������������������� 174
Granting the Key Vault Crypto Officer Role to a User����������������������������������������������������������� 175
Generating a Key in the Azure Key Vault������������������������������������������������������������������������������ 178
Granting Access to the Key by the User-Assigned Managed Identity���������������������������������� 180
Assigning the User-Assigned Managed Identity to the Logical Server�������������������������������� 182
Enabling Customer-Managed TDE��������������������������������������������������������������������������������������� 184
Summary���������������������������������������������������������������������������������������������������������������������������������� 185
v
Table of Contents
Chapter 10: Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI������� 241
Deploying Hyperscale Using the Azure CLI������������������������������������������������������������������������������� 241
The Azure CLI����������������������������������������������������������������������������������������������������������������������� 242
Deploying the Starting Environment������������������������������������������������������������������������������������ 243
The Complete Deployment Bash Script������������������������������������������������������������������������������� 245
Azure CLI Commands in Detail�������������������������������������������������������������������������������������������� 247
Summary���������������������������������������������������������������������������������������������������������������������������������� 264
Chapter 11: Deploying Azure SQL DB Hyperscale Using Azure Bicep������������������� 267
About Azure Bicep��������������������������������������������������������������������������������������������������������������������� 268
Deploying Using Azure Bicep���������������������������������������������������������������������������������������������������� 268
A Complete Azure Bicep Deployment���������������������������������������������������������������������������������� 268
Hyperscale Resources in Azure Bicep��������������������������������������������������������������������������������� 271
Summary���������������������������������������������������������������������������������������������������������������������������������� 284
vi
Table of Contents
vii
Table of Contents
viii
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 461
ix
About the Authors
Zoran Barać is a cloud architect and data specialist
with more than 15 years of hands-on experience in
data optimization, administration, and architecture. He
is a Certified Microsoft Trainer (MCT) and Microsoft
Certified Solutions Expert (MCSE) with a master‘s degree
in information technology. Sharing knowledge and
contributing to the SQL Server community are his passions.
He is also an organizer of the Auckland SQL User Meetup
Group, an active blogger, and a speaker at different SQL events such as Data Summits,
SQL Saturdays, SQL Fridays, meetups, etc.
xi
About the Technical Reviewers
Jonathan Cowley is a cloud infrastructure engineer,
DevOps practitioner, and technical documentation writer
with more than 15 years of experience in various roles and
environments, in both small and large corporations and
public organizations. He has been Microsoft Azure and AWS
certified. He enjoys connecting people and information and
solving challenging problems.
xiii
Introduction
Azure SQL is a platform-as-a-service (PaaS) relational database management system
(RDBMS) that is provided as part of the Azure cloud and based on the Microsoft SQL
Server platform. This offering contains service tiers that make it suitable for a wide
range of use cases, from small single-user applications to mission-critical lines of
business workloads. However, there is only one service tier that provides the high level
of scalability and resilience that is required by some of today’s largest cloud-based
workloads: Hyperscale.
In this book, we’ll take you through the capabilities and basics of the Azure SQL
Database Hyperscale service tier. You’ll learn the basics of designing, deploying, and
managing Azure SQL Hyperscale databases. We’ll look in detail at the resilience (high
availability and disaster recovery) and scalability of Azure SQL Hyperscale databases and
how to tune them. We will also look at the different techniques you can use to deploy and
configure Azure SQL Hyperscale.
Monitoring and securing Azure SQL Hyperscale databases will also be covered to
ensure your workloads continue to perform and operate securely. This book will be your
guide to deciding when Hyperscale is a good fit for migrating your existing workloads
and what architectural considerations you should make in your application. Finally,
you’ll learn how to migrate existing workloads to Azure SQL Database Hyperscale.
This book is intended for data architects, software engineers, cloud engineers,
and site reliability engineers and operators to learn everything they need to know to
successfully design, deploy, manage, and operate Azure SQL Database Hyperscale.
You’ll learn what makes Azure SQL Database Hyperscale architecture different
from a more traditional database architecture and why it’s important to understand the
architecture.
To get the most out of this book, you should have a basic knowledge of public cloud
principles and economics as well as a fundamental knowledge of Azure, Microsoft SQL
Server, and RDBMSs. It is not required to have experience using Azure SQL Database.
This book will provide you with everything you need to know to effectively build and
operate the Hyperscale tier of Azure SQL Database without prior experience.
xv
Introduction
Although this book covers concepts that apply to Azure SQL Database in general,
it is intended to provide everything you need to know to run an Azure SQL Database
Hyperscale tier in Azure without requiring any other material. You may find content that
is covered in other more general books on running SQL in Azure, but this book looks at
these concepts through the Hyperscale lens. Hyperscale has special use cases that make
it unique, which also require specific knowledge to get the most out of it.
Thank you for venturing into the world of Hyperscale database technology.
A note about the recently announced automatic compute scaling with serverless for
Hyperscale in Azure SQL Database: At the time of writing this book, the possibility of
an automatically scaling Hyperscale with a serverless compute tier was merely an item
on the roadmap. We did not, therefore, cover it in detail, even though we were aware it
was planned. However, serverless Hyperscale has just arrived in public preview. This
development does not change the guidance provided in this book, but serverless should
be considered for Hyperscale workloads that need high levels of elasticity. It is yet another
tool in the amazing array of data storage services available in Microsoft Azure and should
be on your list of considerations when determining if Hyperscale is right for you.
Serverless Hyperscale automatically adjusts the compute resources of a database
based on its workload and usage patterns. It also allows different replicas of the
database to scale independently for optimal performance and cost efficiency. Serverless
Hyperscale is different from provisioned compute Hyperscale, which requires a fixed
number of resources and manual rescaling.
For more information on the serverless Hyperscale announcement, see this page
https://techcommunity.microsoft.com/t5/azure-sql-blog/automatic-compute-
scaling-with-serverless-for-hyperscale-in/ba-p/3624440.
xvi
PART I
Architecture
CHAPTER 1
The Journey to
Hyperscale Architecture
in Azure SQL
Every day, many billions or even trillions of transactions are processed by the ever-
growing number of Azure SQL databases deployed globally in the Microsoft Azure public
and government clouds. The number of transactions and the size of these databases
are continuously increasing. The accelerating adoption of public cloud technology has
enabled new use cases for Azure SQL databases as well as the migration of larger line-of-
business applications from on-premises SQL servers.
As the public cloud continues to mature, businesses are moving more of their
mission-critical workloads to Azure. This results in the need to support larger and larger
databases.
Accompanying this move to the cloud, the demand for IT departments and
engineering teams to provide more application features with greater resilience and
security has also increased. This pressure has caused organizations to look at how
they can cut down on the operational costs of maintaining their infrastructure. The
requirement to reduce operational expenditure has led toward running more databases
as platform-as-a-service (PaaS) solutions—where the cloud provider takes care of the
day-to-day operations of the infrastructure—freeing the organization to focus on higher-
value tasks.
As well as the migration of enterprise-scale databases, an increase in the adoption
of software-as-a-service (SaaS) solutions by consumers and organizations has led to
SaaS providers needing larger databases, higher transaction throughput, and increasing
resilience—while also being able to scale quickly.
3
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_1
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
This explosive shift by organizations to adopting SaaS has also facilitated a need by
SaaS providers to manage costs as they scale. This has often resulted in a change from a
single database per tenant to a multitenant approach. A multitenant approach can help
to reduce costs, but it also increases the need for larger capacities and throughput, while
being able to assure isolation and avoid challenges such as noisy neighbors. For an in-
depth explanation on that, see https://learn.microsoft.com/azure/architecture/
antipatterns/noisy-neighbor/noisy-neighbor.
The growth trend toward SaaS is expected to continue as organizations and SaaS
providers accommodate the expectations of their customers to gain greater value
from their data with analytics and machine learning. This growth in demand for better
analytics and machine learning abilities also facilitates the need to collect more data,
such as usage telemetry and customer behavior data.
New types of application workloads and patterns, such as event streaming
architectures and the Internet of Things (IoT), have also increased the demands on
relational database management systems. Although alternative architectures exist to
reduce the impact of these application workloads on the relational database, they don’t
completely mitigate the need for larger relational databases as a part of applications.
Customers are expecting solutions that can integrate with and accept data from other
services and data sources. This is leading organizations and SaaS providers to build a
greater level of integration into their software and also to be seen as platforms with an
ecosystem of third-party applications and extensions springing up around them. This is
further pushing the scale and elasticity required by the relational database management
system (RDBMS) underlying these platforms.
Applications are also consuming data from more and more systems and providing
their own combined insights and enhancements. For example, applications that
integrate with Microsoft Teams might retrieve calling and messaging data and combine
it with other data sources to provide additional functionality. As the volume of data
increases within these systems, so does the need for more capacity in the application
database that collects it.
Azure provides the Azure SQL Database service, a PaaS product, that includes
several different tiers offering options for capacity and resilience while also enabling a
high degree of scale.
The changing data landscape, driven by the cloud, SaaS, and newer workloads, has
resulted in the need for a design change to the Azure SQL Database architecture to be
pushed to the limit, requiring a completely new internal architectural approach: the
Hyperscale architecture.
4
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Hyperscale is the newest service tier of the Azure SQL Database and provides
highly scalable compute and storage that enables it to significantly exceed the limits of
the other tiers of service. This is achieved by substantial alterations to the underlying
architecture. These changes are discussed in more detail in Chapter 2.
Tip Throughout this book we’ll often refer to the Azure SQL Database Hyperscale
service tier as just Hyperscale to make it easier on you, the reader.
SQL on Azure
It’s been a long and progressive journey of more than 12 years from the beginnings of
Azure SQL called CloudDB all the way up to the new Azure SQL Database Hyperscale
service tier and Hyperscale architecture.
Before we can get into the details of Hyperscale, we will start by looking at the
different ways that SQL workloads can be hosted in Azure. This will give us a view of
where Hyperscale fits within the portfolio and when it is a good choice for a workload.
5
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Both Azure SQL deployment types (IaaS and PaaS) offer you redundant, secure, and
consistent cloud database services. However, with IaaS you are responsible for more of
the system, requiring a greater amount of effort from you in maintaining and ensuring
the system is resilient and secure.
Tip Azure SQL MI is a PaaS database service with a higher level of isolation and
compatibility with SQL Server on Azure VMs or on-premises SQL Servers.
Running SQL Server on Azure VMs provides you with the ability to configure every
aspect of the underlying infrastructure, such as compute, memory, and storage as well
as the operating system and SQL Server configuration. This high level of configurability
comes with an increased operational cost and complexity. For example, operating
system and SQL Server upgrades and patching are the user’s responsibility.
By comparison, Azure SQL DB (and Azure SQL MI) is a managed database service
where users do not need to worry about SQL Server maintenance tasks—such as
upgrades, patching, or backups—or service availability. The Azure platform abstracts
and manages these important aspects of your environment automatically, significantly
reducing operational costs and complexity. This often results in a much lower total cost
of ownership (TCO).
Generally, PaaS provides significant benefits that make it extremely attractive;
however, in some cases, IaaS is still required. Some applications might need access to the
underlying SQL instance or features of SQL Server that are not available on Azure SQL DB.
Tip For some workloads that need features that Azure SQL DB does not provide,
Azure SQL MI might still be an option. This could still allow the workload to be
moved to Azure, while leveraging the significant benefits of PaaS. For a comparison
between Azure SQL DB and Azure SQL MI features, see https://learn.
microsoft.com/azure/azure-sql/database/features-comparison.
Workloads that are being migrated from on-premises or a private cloud often require
IaaS when they are first migrated into Azure but will be able to be re-platformed onto
Azure SQL DB after some modernization. The benefits of this usually far outweigh the
engineering costs of modernization. Another reason that IaaS might be needed is to gain
a higher level of infrastructure isolation for regulatory compliance reasons.
6
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Figure 1-1 compares the administration needs and costs of on-premises, private
cloud machines, IaaS, and PaaS. We can see that PaaS has lower administration needs
and costs than IaaS.
We will be focusing primarily on Azure SQL DB, as this is the only deployment model
that supports the newest service tier: Hyperscale.
7
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
There are four key decisions you need to make when deploying a SQL workload
on Azure.
1. Choose a deployment model.
2. Specify a purchasing model.
3. Specify a service tier.
4. Choose an availability model; this will depend on which service
tiers you deployed.
Figure 1-2 shows a map of the deployment models, purchasing models, service tiers,
and availability models available when selecting Azure SQL PaaS. As this book is all
about Hyperscale, the most important area is the Hyperscale service tier.
Figure 1-2. Azure SQL DB deployment models, purchasing models, service tiers,
and availability models
8
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Deployment Models
The PaaS deployment models are divided into two types.
When you deploy an instance of Azure SQL DB, you have two deployment options:
a single database or elastic pools. When using elastic pools, you can allow multiple
databases to share a specified number of resources at a set price.
Tip Elastic pools are an excellent model for building SaaS applications, where
each tenant has their own database; however, elastic pools don’t currently support
Hyperscale.
Azure SQL MI offers both single-instance and instance pool deployment options.
Single instance supports only a single SQL Server instance, while instance pools allow
multiple SQL Server instances.
Table 1-1 shows the deployment options available with Azure SQL PaaS, as well as
the features and recommended use cases.
9
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
• Supports most on-premises instance/ • The most used SQL Server features are
database-level capabilities. supported.
• High compatibility with SQL Server • 99.99 percent to 99.995 percent availability
on-premises. guaranteed.
• At least 99.99 percent availability • Built-in backups, patching, recovery.
guaranteed. • Latest stable database engine version.
• Built-in backups, patching, recovery.
• Latest stable database engine version.
• Easy migration from SQL Server.
Tip You can use the Azure Portal to check the usage and properties for an
existing MI pool, but not to deploy a pool. Instead, use a PowerShell session or the
Azure CLI.
10
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Figure 1-3 shows the compute tier and hardware configuration for the General
Purpose service tier for the Azure SQL Database deployment option.
Figure 1-3. Service and compute tier: Azure SQL DB General Purpose service tier
There are two different purchasing models—vCore and DTU—each with multiple
service tiers. The DTU purchasing model is based on data transaction units (DTUs).
DTUs are a blended measurement of a machine’s specifications—CPU, memory, reads,
and writes. Figure 1-4 shows available purchasing models and service tiers for single
Azure SQL Database deployment.
11
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Figure 1-4. Single Azure SQL DB purchasing models and service tiers available
Tip For more information on DTU modeling, review this page: https://learn.
microsoft.com/azure/azure-sql/database/service-tiers-dtu.
There are multiple service tier options within the DTU purchasing model:
12
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
There are multiple service tier options within the vCore purchasing model.
• General Purpose
• Business Critical
• Hyperscale
You can choose the vCore purchasing model only for managed instances with the
General Purpose or Business Critical service tier.
13
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Depending on which service tiers you deployed, it may leverage the Standard
availability architecture for the Basic, Standard, and General Purpose service tiers or the
Premium availability architecture for the Premium and Business Critical service tiers.
There are three types of redundancy when running SQL workloads in Azure.
14
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Depending on which service tier you select, it may leverage either the Standard or
Premium availability architecture model.
15
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
16
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Tip Be aware that with the General Purpose service tier, the zone-redundant
option is available only when the Gen5 (or newer) hardware configuration is
selected. Selecting zone redundancy incurs an additional cost.
Figure 1-6 shows the Azure SQL PaaS Standard availability model with zone
redundancy used by the General Purpose service tier.
Figure 1-6. Azure SQL PaaS Standard availability model with zone
redundancy enabled
17
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
18
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
19
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Tip Azure SQL Database service tiers using the Standard availability model
provides a greater than 99.99 percent uptime availability guarantee. Nevertheless,
Premium and Business Critical service tiers—leveraging the Premium availability
model with zone-redundant deployments—provide a greater than 99.995 percent
uptime guarantee.
Figure 1-8 shows the Azure SQL PaaS Premium availability model with zone
redundancy enabled for the Premium and Business Critical service tiers.
20
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Figure 1-8. Azure SQL PaaS Premium availability model with zone
redundancy enabled
21
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Figure 1-9 shows geo-replication using failover groups via asynchronous replication
between multiple Azure regions.
Figure 1-9. Geo-replication between multiple Azure regions using failover groups
22
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
The goal of the new model has been to decouple compute, storage, and log services,
while at the same time offering highly scalable storage and compute performance tiers.
At the time of writing, there is an Azure SQL database deployment model and the
Hyperscale service tier under the vCore purchasing model, which leverages a new
architecture, which in this book we will call the Hyperscale architecture.
Table 1-2 compares the traditional Azure SQL architecture and the Azure Hyperscale
architecture.
Table 1-2. Traditional Azure SQL Architecture vs. Azure Hyperscale Architecture
Traditional Architecture Hyperscale Architecture
Tip The main question you should ask yourself is whether your data workload
demands are exceeding the limits of your current Azure SQL service tier—in which
case you might consider moving your data workload to a more suitable service tier
such as Azure SQL Hyperscale, leveraging the Hyperscale architecture scale-out
capability.
24
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
25
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
Tip Deploying services using the Azure Portal is a great way to get started,
but it is strongly recommended that as you mature in your use of Azure, you
adopt infrastructure as code. To learn more about infrastructure as code,
refer to https://learn.microsoft.com/devops/deliver/what-is-
infrastructure-as-code. We will favor using infrastructure as code in the
examples throughout this book.
You will need access to an Azure subscription that you have appropriate permissions
to create new services in. The Contributor or Owner role in the Azure subscription will
be adequate permissions. If you’re not the subscription owner, you should first check
with the account owner for the subscription if you may deploy a Hyperscale database as
there will be a cost for every hour that you have the service deployed.
Tip If you don’t have access to an Azure subscription, you can sign up for a free
Azure one with USD $200 credit to use within 30 days; see https://aka.ms/
AzureFree. After you have consumed the USD $200 credit, the free services will
still be available to you for one year, but unfortunately the Hyperscale tier of Azure
SQL DB is not currently among the free services.
The Azure Portal is under constant improvements, and it is quite possible that the
user interface you see by the time this book is released will be slightly different. But
the fundamental elements should remain. That is a reason why we will provide many
examples as code.
In our example, we’re going to deploy a zone-redundant Hyperscale database with
two vCores running on Gen5 hardware in the Azure East US region with one high-
availability secondary replica.
So, let’s get started.
1. Open your browser and navigate to https://portal.azure.com.
2. Sign in using credentials that give you access to the Azure
subscription you’ll be deploying your Hyperscale database into.
3. Click the “Create a resource” button in the home dashboard.
26
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
5. The Create a SQL Database blade will open showing the Basics
configuration options of our database.
27
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
7. Set the resource group to an existing resource group that you want
to create your Hyperscale database into or click New to create
a new resource group. In our example, we are going to create
our hyperscale resources in an existing resource group called
sqlhyperscalerevealed-rg that is in the Azure East US region.
28
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
10. Every SQL Database server must have a unique name, not just
within our environment, but globally. For this example, we are
using sqlhyperscalerevealed01, but you should use a name that
is likely to be globally unique.
11. Set the location to the Azure region in which you want to deploy
the SQL Database server. This is the Azure region where your
Hyperscale database will be stored and should usually be as
geographically close to your application or users as possible.
12. Set the authentication method to “Use only Azure Active Directory
(Azure AD) authentication.”
Tip You can choose to use SQL authentication or to use both SQL and Azure AD
authentication, but it is recommended you use Azure AD authentication to enable
the central management of identities. However, some third-party applications may
not support this. We will cover security best practices in detail in Chapter 15.
13. Click the “Set admin” button to select the Azure AD user or
group that will be granted the admin role on this SQL Database
server. But for this example, we will select our own Azure AD user
account to be the admin.
Tip It is good practice to set the admin role to a separate Azure AD group that is
created for this SQL Database server. Membership in this group should be carefully
governed.
29
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
30
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
23. Specify Yes when asked if you would like to make this database
zone redundant.
25. We will return to the Create SQL Database blade again. We will not
change any of the other deployment options, such as Networking
and Security for this example, as we can change most of them
after deployment.
31
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
27. Review the estimated cost per month and scan through the
configuration to confirm we’re configuring what we expected.
There are ways to reduce the estimated cost per month (such
as purchasing reserved capacity), but these will be discussed in
Chapter 16.
Important The Azure SQL Database Hyperscale tier is billed hourly. So, once the
resources are deployed, you’ll begin to be billed. Deleting the database resource
will cause you to stop being billed, but you will be charged for at least one hour.
29. After a few seconds, our resources will begin to be deployed, and a
deployment progress window will be displayed.
32
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
30. Once the deployment has been completed, we can click the
sqlhyperscalerevealed01/hyperscaledb resource (or whatever
you called it in your subscription) to be taken directly to the
database.
Congratulations! You have deployed your first Hyperscale database and can begin
to use it. There are other administrative tasks we would typically do from here, such
as granting access to the database and opening network access to our applications
and users, but they will all be covered in later chapters. For now, this is enough to
demonstrate just how easy it is to get a Hyperscale database up and running in Azure.
33
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
C
leaning Up
Like most services in Azure, you are charged only for what you consume. Therefore,
cleaning up any unneeded resources is a good idea to manage your costs. Although
we’re going to use the Hyperscale database we’ve deployed here throughout this book,
you can go ahead and delete it and then re-create it again later.
To delete the Hyperscale database using the Azure Portal, follow these steps:
1. Open your browser and navigate to https://portal.azure.com.
5. You should also delete the SQL Database server that hosted the
Hyperscale database. This is because it may also incur charges
(such as Microsoft Defender for SQL licenses).
6. Navigate to the Overview tab of the SQL Server and click the
Delete button.
34
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
7. Type in the name of the SQL Database Server and click Delete.
Now that we have seen the different options for deploying SQL in Azure and have
deployed our first Hyperscale database, in the next chapter we’ll look at the Hyperscale
architecture in more detail. This will help us understand how it differs from other Azure
SQL PaaS architectures and why it can be used for workloads that need higher storage
and scalability.
S
ummary
In this chapter, we took a high-level look at the basic options for running SQL workloads
in Azure and introduced the basic concepts of the Azure SQL Database Hyperscale tier.
We walked through some of the key concepts that should be considered when deploying
SQL on Azure, including the following:
35
Chapter 1 The Journey to Hyperscale Architecture in Azure SQL
• The service tiers: Provides you with additional control over the
service-level objectives and features of the database. This also
includes vCore and DTU capacity models. Hyperscale currently
supports only vCore capacity.
36
CHAPTER 2
Tip In this chapter there are some Transact SQL (T-SQL) and Azure CLI samples.
These will all be available in the ch2 directory in the files accompanying this book
and in the GitHub repository: https://github.com/Apress/Azure-SQL-
Hyperscale-Revealed.
37
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_2
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
In this chapter, we will examine in more depth the architectural differences with
Hyperscale that enable it to provide improvements in performance, scale, and storage
when compared with other tiers of Azure SQL Database. The multitier architecture lies at
the heart of this architectural transformation, so we will spend the majority of our time
on it in this chapter.
38
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
• Compute: Stateless, with sqlserver.exe running with locally attached SSD for transient data,
such as tempdb, buffer, etc.
• Storage: Stateful, with database files (.mdf/.ldf) stored in Azure Blob Storage. Premium locally
redundant storage (LRS) is used by default. If the zone-redundant option of the General Purpose
service tier is enabled, then zone-redundant storage (ZRS) is used.
• Zone redundancy: Optionally available for the General Purpose service tier only, in which case
secondary nodes will be created in different availability zones.
• Architecture: Like the Failover Cluster Instance (FCI) approach to running Microsoft SQL Server
with storage shared between all nodes in the cluster.
Premium Availability Model: Premium and Business Critical Service Tier Availability
• Compute: Sqlserver.exe running with locally attached SSD for transient data, such as
tempdb, buffer, etc. Including SQL data and log files, they are as well stored on a locally attached
SSD and automatically replicated to additional secondary nodes, creating a four-node cluster.
• Zone redundancy: Available. Each deployment contains four nodes for achieving high availability.
Secondary replicas are in sync commit and contain a full copy of the primary database.
• Architecture: Like the Windows Failover Cluster (WFC) approach, which uses the Always On
Availability Group configuration with all nodes in sync commit and hold full copy of database.
(continued)
39
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Standard Availability Model: Basic, Standard, and General-Purpose Service Tier Availability
• Compute: Stateless, with sqlserver.exe running with a locally attached SSD for the RBPEX
Data Cache (discussed later in this chapter) and transient data, such as tempdb, buffer, etc. One
primary node with four secondary replicas. There is one primary node and up to four secondary
high-availability replicas. You can have additional geo replicas for disaster recovery and up to 30
named secondary replicas.
• Storage
• Page servers: Stateless second cache layer in the Hyperscale architecture containing transient
and cached data (covering RBPEX cache). Each page server also has a replica for redundancy
and high-availability purposes, which means that we have two page servers in an active-active
configuration.
• Log service: Stateful completely separated tier containing transaction logs.
• Data storage: Stateful, with database files (.mdf/.ldf) stored in Azure Blob Storage and updated
by page servers. This uses the redundancy features of Azure Storage.
• Zone redundancy: Available. Each stately compute replica can be optionally spread across
availability zones.
• Hyperscale utilizes the snapshot feature of Azure Standard Storage to make snapshot backups
easy and fast without impacting user workloads.
40
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
41
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
This DMV returns the configuration and capacity settings for the current database.
Table 2-2 shows an example of these results on a Hyperscale database in Azure with two
vCores assigned.
42
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
This DMV returns a single row describing the configuration of the job object,
including certain resource consumption statistics. In our example, this returns the
memory_limit_mb column, which presents the maximum amount of committed memory
for the SQL Server compute node. Table 2-3 shows the result of running this query on
a new Hyperscale database with two vCores. It shows approximately 10GB of memory,
which is what we expected based on the earlier calculation.
10630
Finally, let’s obtain the RBPEX cache size in storage. To do this we are going to query
the sys.dm_io_virtual_file_stats DMV and look for the number of bytes used on the
disk for this file (size_on_disk_bytes), as shown here:
SELECT database_id, file_id, size_on_disk_bytes/1024/1024/1024 as Size_on_disk_
GB FROM sys.dm_io_virtual_file_stats(DB_ID(), NULL)
43
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
This dynamic management function returns I/O statistics for data and log files. The
database_id and file_id columns will have a value of 0 for the Resilient Buffer Pool
Extension. Table 2-4 shows the query results from querying this DMV on a Hyperscale
database with two vCores assigned.
Table 2-4. Query Result from the sys.dm_io_virtual_ file_stats DMV to Get the
Size of the RBPEX Cache on Disk for a Two-vCore Hyperscale Database
database_id file_id Size_on_disk_GB
0 0 32
As we can see, the RBPEX cache is 32GB, which is approximately three times the
memory allocated to the compute node, which is 10GB.
44
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
21260
0 0 63
This again demonstrates that the amount of storage assigned to the RBPEX cache
is three times the amount of memory available to the compute node. In the case of
our four-vCore Hyperscale database, it is 20GB memory with 60GB assigned to the
RBPEX cache.
45
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Table 2-8 shows the relationship between isolation levels, reads, and locks.
Table 2-8. Snapshot and Read Committed Snapshot Transaction Isolation Levels
on a Hyperscale Database
Isolation Level Dirty Reads Nonrepeatable Reads Phantom Reads
Snapshot No No No
Read Committed Snapshot No Yes Yes
46
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Note The copy data process will occur prior to any change being made. Copied
data (version_ghost_record) will be stored in the version store within tempdb
and will contain latest committed record before any new transaction changes
the data.
What does this mean for the Hyperscale architecture? The main consistency
behavior difference between traditional Azure SQL Database service tiers and the
Hyperscale service tier is that with the traditional Azure SQL service tiers, versioning
occurs in the local temporary storage. This means that row versions are available only
locally to the primary replica. The Hyperscale architecture extends the shared disk ability
in such a way that compute nodes must make row versions available in a shared storage
tier to create a shared and persistent version store.
47
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
• Undo: The database engine undoes all transactions that were active
at the time of the crash.
Before ADR, the usual time necessary for a database engine to recover from an
interrupted transaction, including the rollback of all incomplete transactions, was a lot
higher—often close to the same amount of time originally needed for the execution.
Long-running transactions were particularly affected by such a recovery model.
Moreover, this could cause potential log issues since the database engine cannot
truncate the transaction log until the transaction is committed or rolled back.
Tip Bear in mind that rollback is mostly single threaded. Even if your transaction
used multiple cores to run, the rollback is going to use only one, so it will take
more time for the rollback to finish.
48
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
The combination of the ADR feature and the persistent version store within Azure
SQL offerings improved this recovery process significantly, by eliminating the need for
the undo phase.
The Hyperscale architecture goes one step further by utilizing the shared drive
concept and by making a shared persistent version store available to all page servers—
instead of storing it on the local tempdb as per the traditional Azure SQL architecture.
There are some ADR improvements in regard to the persistent version store publicly
available in SQL Server 2022 such as the following:
Why is this important for Azure SQL PaaS offerings? Azure SQL PaaS offerings are
usually ahead of the on-premises version of SQL Server when compared to the SQL
Server versions that are being used. This includes the latest security fixes and latest
features available in the latest SQL Server versions.
• Compute nodes
• Log service
• Page servers
• Azure Standard Storage
Figure 2-2 shows a diagram of the four tiers making up the Hyperscale architecture.
49
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Compute Nodes
The Hyperscale architecture provides rapid compute scalability to support workload
demands. The Azure SQL Database Hyperscale service tier has two types of compute
nodes, as follows:
Figure 2-3 shows the pane for creating a compute replica in the Azure Portal.
50
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Figure 2-3. Creating compute primary and secondary replicas via the
Azure Portal
One of the biggest advantages of the Hyperscale architecture is its rapid compute
scalability—the ability to rapidly scale up or down your compute resources to support
your current workload as needed. It also allows you to rapidly scale out by adding more
read-only replicas to offload your read workloads if required.
51
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Tip Bear in mind you cannot pause compute nodes to reduce the cost of the
Hyperscale service tier; however, you can automate the downscaling of your
compute node when there is no heavy workload.
• High-availability replicas
• Named replicas
• Geo replicas
Figure 2-4 shows the named and geo-replicas configuration options available when
creating a new replica. The high-availability replica is part of the initial deployment
process of the Hyperscale database.
52
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Note Both named replicas and geo replicas can be deployed with their own high-
availability replicas. This is especially important for using geo replicas in disaster
recovery scenarios as we would usually want the same level of resilience in our
failover region.
High-Availability Replicas
High-availability (HA) replicas are part of the Azure SQL Database Hyperscale
deployment process. In a Hyperscale architecture, HA secondary replicas always have
the same configuration and number of vCores as the primary node. HA replicas are a
key part of high availability, and if a failover happens, they need to be able to provide the
same performance to support the workload in place of the primary node. To improve
availability, you can simply increase the number of HA replicas to a maximum of 4.
Figure 2-5 shows the HA replicas configuration option.
53
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
• Failover
• Read-only replicas
Bear in mind, even if you did not choose any high availability replicas during
deployment, you will still have local redundancy within the Hyperscale service tier. Data
files are stored in Azure Standard Storage. If failover should occur, the first available
node with spare capacity will take the role of the primary compute replica. It will then
start feeding the data from the page servers and Azure storage. Failover will be somewhat
slower than would be the case if you had a secondary replica in place.
HA replicas have several benefits.
• Easy deployment
• You do not have full control over the HA replicas configuration. You
will not have visibility of them in the Azure Portal.
Named Replicas
A named replica (read-only) is an independent node, and it uses the same page servers
as the primary compute node. The Hyperscale service tier supports up to 30 named
replicas, and it allows you to choose your desired compute tier for these replicas,
independent from your primary compute nodes.
54
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
These replicas can be viewed and managed via the Azure Portal, Azure CLI, or
PowerShell, and you will have full control over them. There are several advantages to
these replicas.
Some of the common use case scenarios would be the need for near real-time
analytics, reporting, or other online analytical processing (OLAP) workloads. Moreover,
it can apply anywhere there is a need for a massive online transaction processing (OLTP)
read scale-out, such as for example API, ecommerce, or online gaming.
Additionally, you can utilize these named replicas based on your workload and limit
or isolate the access per workload type (complex analytics, for example). You can also
dedicate them to a particular service usage (PowerBI, for example), or you can route
traffic to specific replicas based on traffic source (mobile apps, for example).
Tip Bear in mind that named replicas cannot be your choice for failover
scenarios. For that purpose, Hyperscale uses high-availability replicas.
55
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
To create a new Azure SQL logical server and add a named replica to it using the
Azure CLI, use the following:
For more secure use-case scenarios, you have an option to create named replicas on
a different logical SQL server.
56
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Important A logical SQL Server needs to be in the same Azure region as the
logical SQL server hosting the primary compute replica.
Geo Replicas
Geo replicas can cover disaster recovery scenarios in the case of a regional outage
and must be on a different logical SQL Server instance from the primary replica host.
Figure 2-7 shows the pane for creating a geo replica in the Azure Portal.
The database name of a geo replica database will always remain the same as the
database name of the primary node. Nevertheless, you can have different compute and
storage configuration for primary and secondary named or geo replicas. You can also
specify a different ratio of secondary replicas compared to what you have on the primary
compute node configuration. A geo replica can also be configured with its own high-
availability replicas.
Tip Keep in mind that latency may occur on any secondary replica, either HA,
Named, or GEO. Moreover, if you deployed multiple secondary replicas, you may
notice different data latency for each replica.
57
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Figure 2-8 shows the ability to change the compute and storage configuration for
your secondary replicas in the Azure Portal.
Figure 2-8. Compute and storage configuration options for secondary named or
geo replicas
Log Service
One of the main advantages of the Hyperscale architecture compared to traditional
architecture is that the transaction log service is separated from the primary compute
node. This separation concept was introduced by Microsoft to help achieve lower
commit latencies. The general concept of this would be to receive changes from the
source, which is the primary compute node, and send those changes to multiple page
servers and secondary compute replicas.
Tip The Log service process does not run sqlserver.exe. It has its own
executable called xlogsrv.exe.
58
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
The Log service in Hyperscale is a multitier design and contains the following:
• Log service node with staging area, log broker, SSD cache
59
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Log records are available for up to 35 days for point-in-time restore and disaster
recovery in Azure Standard Storage. For the PITR backup retention period, any options
longer than seven days were in preview at the time of writing.
Tip Differential backups are not supported for the Hyperscale service tier, unlike
for other service tiers in traditional architecture.
Figure 2-10 shows the backup retention policy configuration pane in the
Azure Portal.
60
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Page Servers
Page servers are the second cache layer in the Hyperscale architecture. They present
a part of the storage layer that contains transient and cached data. To accomplish this
caching objective, page servers rely on the RBPEX cache using the attached SSD and
cached data pages in memory.
61
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
One of the roles of the page servers is to serve data pages to the compute nodes when
required. The page servers themselves are updated by transaction log records from the
log service. Each page server can contain between 128GB per file and approximately
1TB per file. As soon as the file size reaches a certain percentage of its maximum size, an
additional page server node will be added automatically. The percentage for when this
page server node increase occurs is determined automatically by Azure.
Note In the Hyperscale architecture, the data files are stored in Azure Standard
Storage. Regardless, each page server maintains a subset of the data pages and
has them fully cached on local SSD storage.
SELECT file_id
, name AS file_name
, type_desc
, size * 8 / 1024 / 1024 AS file_size_GB
, max_size * 8 / 1024 / 1024 AS max_file_size_GB
, growth * 8 / 1024 / 1024 AS growth_size_GB
FROM sys.database_files WHERE type_desc IN ('ROWS', 'LOG')
This sys.database_files DMV returns a row per file of a database. In our example,
this returns the current size of the file, in 8KB pages, as well as the maximum file size,
in 8KB pages. Table 2-9 shows the results of running this query on an empty Hyperscale
database.
62
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Tip For more information on the sys.database_files DMV, see this page:
https://learn.microsoft.com/sql/relational-databases/system-
catalog-views/sys-database-files-transact-sql.
After inserting dummy data into the database, in this case 64GB, we reach the
threshold at which a new page server is added. Hyperscale automatically adds an
additional page server with the max file size of 128GB.
If we run same query as earlier, we get the results shown in Table 2-10.
After inserting another 64GB data to the database (making a total of 128GB data
inserted), an additional page server is created, and now we have three page servers, as
shown in Table 2-11.
Table 2-11. The Page Servers After Adding Another 64GB of Data
file_id file_name type_desc file_size_GB max_file_size_GB growth_size_GB
Since the growth size per data file is in 10GB increments, this 180GB total size is not
necessarily used space; it is rather allocated space for this example.
63
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Important Although in the previous example each page server had a maximum
file size of 128GB, we are charged only for the storage used. That is the file_
size_GB value.
As mentioned earlier, each page server can contain between 128GB and 1TB
total data per file. In all our previous examples, we were presenting page servers with
a maximum of 128GB per file. In the following example, we will show the resulting
page servers after we migrate an Azure SQL Database instance from General Purpose
to Hyperscale if it contains more data than the initial maximum page server size of
128GB. If the initial size of the data file is larger than 128GB, the page server maximum
data file size will be adjusted to accommodate the larger data file size. Figure 2-11 shows
the used and allocated storage space of an Azure SQL Database General Purpose service
tier in the Azure Portal before being migrated to the Hyperscale tier.
Figure 2-11. Database data storage, used and allocated storage space in the
Azure Portal
64
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
After the migration from the General Purpose to the Hyperscale service tier is
finished, we can run the same query as we did in the previous examples using the sys.
database_files DMV. As we can see, the maximum file size has been changed and is no
longer 128GB; it has increased to 384GB, three times larger than in the first example.
Table 2-12. The Page Servers After Migrating from a Database with 134GB
of Storage
file_id file_name type_desc file_size_GB max_file_size_GB growth_size_GB
Note Bear in mind each page server can handle up to approximately 1TB data
file size. If you are migrating your database to Hyperscale with a data file size
bigger than 1TB, your data file is going to be split into smaller multiple files after
migration is finished.
The next example shows the behavior of the page servers when we migrate a
database that contains more than 1TB of data, which is larger than the maximum page
server file size. This demonstrates that the maximum size of the data file per page server
can differ within a database. For example, when we migrate an Azure SQL database
from the Business Critical to the Hyperscale service tier with a database size of 1.12TB,
we will have multiple page servers with a maximum data file size per each page server
determined by Azure.
Figure 2-12 shows the used and allocated storage space of an Azure SQL Database
Business Critical service tier with 1.12TB of data in the Azure Portal before being
migrated to the Hyperscale tier.
65
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Figure 2-12. Azure SQL Database Business Critical service tier with more
than 1TB
After the migration to the Hyperscale service tier is complete, the Azure Portal
database storage pane will look like Figure 2-13.
As we can see in Figure 2-14, the maximum data file size per each page server varies,
and it has grown in 128GB increments.
66
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Azure determines what the maximum data file size for each page server should be,
and once that size is set, it cannot be changed. Figure 2-15 shows the page servers after
inserting more data into the previous Hyperscale database. It shows that each newly
added page server can contain 128GB of data.
Each page server always has a replica, in active-active configuration, for the purposes
of redundancy and high availability. This means both page servers are fully independent
of each other and are both able to serve requests at the same time. Each page server
has its own file data subset on Azure Standard Storage. The primary compute node can
communicate with either of these page servers in an active-active mode. Figure 2-16
shows page servers in active-active configuration.
67
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
The page servers are part of a scaled-out storage engine. This is because one of the
roles of the page servers is to maintain and update the data files that are stored in Azure
Standard Storage.
Note In the Hyperscale architecture, all data files are managed by page servers.
68
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Having both the data files and log files on Azure Standard Storage makes this
snapshot backup easy and fast.
Tip The snapshot backup file is in fact not a full backup, only a small differential
copy from a base file with a timestamp on it.
2. It finds the LSN of the oldest transaction from the time of the
latest snapshot from the long-term storage, which holds the
transaction logs.
3. The new page servers that are created will be synchronized from
the latest snapshots.
4. The new log service synchronizes its landing zone using premium
storage from the available transaction logs in long-term storage.
5. Once the new primary compute node is online, it will pick up logs
from the new landing zone. All this happens quickly due to the
ADR feature.
Figure 2-17 shows a diagram of how the point-in-time restore process works.
69
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
70
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
transaction logs may be applied only in the case where there is a read request that needs
pages that require those specific logs.
Figure 2-18 shows compute nodes routing read-write and read-only connections.
All other read transactions that do not request a read-only workload will go through
to the primary compute node. As previously mentioned, compute replicas do not store
the full database in their local cache. Compute replicas use their buffer pool and their
RBPEX cache (noncovering cache) to store data pages, though only partially. If pages are
not available within the compute nodes’ buffer pool (in memory) or their RBPEX cache,
the next step is to check the page servers. Those reads will be counted as remote reads
and will be somewhat slower than reading those pages from compute nodes directly.
Figure 2-19 shows how the primary compute node and page servers interact.
71
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Figure 2-19. Relationship between primary compute node and page server
The compute nodes use their RBPEX caches to store information about requested
pages. If the page requested does not exist on the primary compute node’s buffer pool
or local RBPEX cache, then the primary node needs to know which page server it should
send GetPage@LSN request to.
After the LSN request is sent to the right page server, for a page server to be able to
return the page, the log sequence number should be up-to-date.
Only once the page server is up-to-date with the LSN will it return the page to the
primary replica. Otherwise, it will send a GetLogBlock request to the Log service, then
get and apply that log, and finally return the page to the primary replica. This waiting
time will be counted toward the PAGEIOLATCH wait type. Figure 2-20 shows Log service’s
Hyperscale tier interaction with compute nodes and page servers.
72
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
In terms of the write requests, all requests from the primary compute node will
go directly to the log service, which is a separate tier in the Hyperscale architecture.
From the primary compute node, the log is written to a landing zone that sits on Azure
Premium Storage.
For the purposes of point-in-time restore processes, the Log service tier has its long-
term storage, which sits on Azure Standard Storage. This way, the Log service can serve
the log from Azure Premium Storage with faster I/O.
The XLOG process is a part of the Log service tier. The process uses its memory and
SSD cache to hold and process the incoming log blocks. The Log Broker then serves the
secondary replicas and page servers with log changes.
73
Chapter 2 Azure SQL Hyperscale Architecture Concepts and Foundations
Summary
In this chapter, we gave you an overview of the foundations and concepts that make
up the Hyperscale architecture. We looked at the Resilient Buffer Pool Extension and
how it provides the ability to leverage fast SSD storage to enable a larger and more
resilient cache.
We discussed the remote durable storage service, as well as the new architecture’s
shared-disk design, shared version store, and ability to recover more quickly after
transaction failures.
We explained the reasons behind decoupling the compute nodes from the storage
layer and the database log service into the four tiers creating the Hyperscale multitiered
architecture. We discussed the four tiers and what they enable.
• Log service: The XLOG process and Log Broker ensure writes are
available to secondaries quickly.
• Page servers: Page servers are the second caching layer in the
Hyperscale architecture and they present part of the storage layer
that contains transient and cached data used by the compute nodes
and log service.
74
PART II
Planning an Azure
SQL DB Hyperscale
Environment
Now that we’ve completed a short tour of the SQL on Azure landscape and taken a
high-level look at how the Hyperscale architecture differs, it’s time to look at planning a
production Azure SQL DB Hyperscale environment.
At the end of Chapter 1, we deployed a simple Azure SQL DB Hyperscale instance
that was ready to be used. However, in a real-life production deployment of Azure SQL
Hyperscale, we’re likely to have additional nonfunctional requirements that we’ll need
to satisfy. In this chapter, we’ll take a look at some of the key considerations you’ll need
to make to satisfy these additional requirements, including high availability, disaster
recovery, connectivity, authentication, security, and monitoring.
77
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_3
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Understanding and planning for these requirements before you deploy your Azure
SQL Hyperscale database will result in better outcomes. In most cases, your Hyperscale
database can be adjusted after deployment, but not meeting critical requirements such
as security or cost can have a large impact on your business.
Tip You may have noticed that the previous categories align to some of the Azure
Well-Architected Framework (WAF). This is intentional as when you’re designing
a solution in Azure, you should be reviewing and consulting the Well-Architected
Framework. For more information on the WAF, see https://aka.ms/waf.
78
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
The SQL Server resource is known as a logical server. We will refer to this resource
simply as the logical server throughout this book. A single logical server can host
multiple Azure SQL Database instances (up to 5,000 at the time of writing). It can host
multiple Hyperscale databases or single databases or a mixture of both.
A logical server can also host multiple elastic pools, with the maximum being
determined by the number of eDTUs or vCores in each elastic pool. But because this
book focuses on Hyperscale (which can’t be contained in an elastic pool), we won’t go
into more detail on this.
Tip The limits of Azure SQL Database are constantly increasing, so by the time
you read this, the number of databases that can be hosted by a logical server may
have increased. For the current limits of a logical server, please review https://
learn.microsoft.com/azure/azure-sql/database/resource-limits-
logical-server.
Figure 3-2 shows a conceptual diagram of the relationship between a logical server
and the Azure SQL Databases or Azure SQL elastic pools that use it.
79
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Note There is no guarantee that the compute and storage of each database in a
logical server is physically located close together, although they will be within the
same Azure region.
All Azure SQL Database instances within a logical server share the following:
• Azure MI: The account in Azure Active Directory that the logical
server and databases can use to access Azure resources.
80
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Important Because many of the concepts in this section apply to the logical
server, they will also apply to Hyperscale databases, single databases, and elastic
pools. Where a concept or feature is specific to Hyperscale databases and doesn’t
apply to single databases or elastic pools, it will be noted.
Now that we have defined what a logical server represents, we can go into more
detail about the key decisions we have to make when planning to deploy a Hyperscale
database.
• Disaster recovery: The ability to recover from a system outage and the
ability to recover damaged or lost data; usually defined by specifying
a recovery time objective (RTO) and recovery point objective (RPO).
These are usually specified in minutes, hours, or sometimes days.
The lower the RTO, the faster a solution can be recovered in a disaster
(e.g., a regional outage). The lower the RPO, the less data that may be
lost in a disaster/data loss scenario.
81
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
In this section, we’ll cover in detail the Azure SQL Hyperscale database features that
help us meet availability and disaster recovery requirements.
Note Although named replicas are included under reliability, they are not typically
used to increase resilience. Rather, they’re traditionally used to enable read
scale-out scenarios and to improve performance efficiency.
• Backup: This protects against data loss. This affects the RPO of
your solution, but if you’re not using replication, it also affects the
availability and RTO.
High-Availability Replicas
When you deploy a Hyperscale database, you can choose the number of high-availability
secondary replicas you want to deploy, from zero to four. These high-availability
secondary replicas are deployed within the same Azure region as the primary and share
the page servers. This means that no data copy is required to add new replicas. The
secondary replicas help prevent unplanned disruption to your workload.
82
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Tip Even if you do not deploy any high-availability secondary replicas with your
Hyperscale database, your workload is still protected against disruption due to
planned maintenance events. This is because the service will automatically create
a new replica before initiating a failure. For more information, see https://
learn.microsoft.com/azure/azure-sql/database/service-tier-
hyperscale?view=azuresql#database-high-availability-in-
hyperscale.
Tip This section assumes you are familiar with the concept of availability
zones within Azure. If you’re not familiar or would like to brush up, please review
https://learn.microsoft.com/azure/availability-zones/az-
overview.
The following are the two options that control how your secondary replicas are
deployed within the region:
83
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Figure 3-3 shows the potential impact of using locally redundant high-availability
secondary replicas when an outage of an availability zone occurs. This shows that the
workload will be disrupted and would need to be failed over to a different region, if you
had enabled geo-replication.
Figure 3-4 shows what occurs when the availability zone containing the primary
replica is disrupted. The application simply connects to one of the secondary replicas in
a different zone and continues operating without disruption.
84
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Primary Primary
When choosing the level of high availability you want to implement, it is a decision
based on resource cost versus resilience as choosing the number of replicas does not
increase the complexity of the solution.
Figure 3-5 shows creating a new Hyperscale database with two high-availability
secondary replicas in a zone-redundant fashion.
85
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Named Replicas
Named replicas are like high-availability (HA) secondary replicas. Like HA replicas,
they share the underlying page servers of the primary database. But they do differ in the
following ways:
86
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Important Although named replicas can increase availability if you aren’t using
high-availability replicas, it is not the primary use case. They are typically used to
enable read scale-out scenarios and to improve hybrid transactional and analytical
processing (HTAP) workloads.
Figure 3-6 shows the conceptual architecture for named replicas. The two named
replicas are replicas of the Hyperscale database, but the first is attached to logical server
1, and the second is attached to logical server 2.
Figure 3-7 shows the Replicas blade on an Hyperscale database in the Azure Portal. A
named replica exists called hyperscaledb_replica. Clicking the “Create replica” button
allows us to create new named replicas (or geo replicas).
87
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Figure 3-8 shows the named replica creation step from an existing Hyperscale
database.
88
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Geo Replica
The geo replica feature of Azure SQL Database Hyperscale provides a more traditional
replication implementation with the data being copied from the primary to a separate
set of page servers for the replica.
Geo replicas have the following properties:
• The database name of the replicas is always the same as the primary
Hyperscale database.
Figure 3-9 shows the conceptual architecture when using geo-replication with a
Hyperscale database.
89
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Async
Async
Geo replicas are typically used to mitigate against the outage of an entire Azure
region and provide all the necessary infrastructure to perform geo-failovers.
Backup
Performing database backups is the simplest and most common way to prevent data
loss. It should not be a surprise that performing automated database backups is a basic
feature of Azure SQL Databases. However, because of the unique Hyperscale storage
architecture, Hyperscale database backups have some special properties, listed here:
90
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
When you enable Hyperscale database backups, you can choose the
redundancy of the storage used to store your backups. There are three
options available that will affect the resilience of backups.
91
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Tip To enable the geo-restore feature of Azure SQL Databases, you must be
using geo-redundant or geo-zone-redundant backup storage for your Hyperscale
database. Geo-restore allows you to restore your Hyperscale database to the
paired Azure region in the case of a regional outage.
The remaining decision you need to make when considering backups on your
Hyperscale database is to define the short-term retention policy (STR). This can be
between 1 and 35 days, but it defaults to 7.
Figure 3-10 shows how to configure the backup retention policies for a Hyperscale
database in the Azure Portal using the Backups blade of the logical server.
92
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
When planning how we should configure backup for our Hyperscale database, it
comes down to balancing cost with our resilience requirements as the new Hyperscale
storage architecture eliminates the issue of performance impact when performing
a backup.
93
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
94
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Public Internet
Public
sqlhyperscalerevealed01. endpoint
database.windows.net
Firewall
Hyperscale
Database
Private
sqlhyperscalerevealed01.
endpoint
privatelink.database.windows.net
With each client that will need to use your database, you will need to determine
whether public or private connectivity can be used and is required.
Important Some clients, such as external SaaS applications, may not be able to
use a private endpoint. So, if you have a requirement for a SaaS application that
can’t use a private endpoint to access the database, then you’ll have to factor this
into your planning.
Public Endpoint
Every Azure SQL logical server has a public endpoint with a DNS name on the Internet.
However, this can be disabled completely or filtered based on the originating traffic.
For logical servers hosted in the Azure Public cloud, the fully qualified domain name
(FQDN) will be as follows:
yourservername.database.windows.net
95
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
For logical servers in Azure Government or Azure Sovereign clouds, the FQDN will
differ. You can check the FQDN of your logical server in the Azure Portal on the Overview
blade of the logical server, as depicted in Figure 3-12.
Figure 3-12. Locating the FQDN of the logical server in the Azure Portal
You can also use Azure PowerShell or Azure CLI to return the FQDN of the logical
server. For example, to return the FQDN of the logical server using PowerShell, use the
following:
This is the output when the command is run using Azure Cloud Shell with
PowerShell:
This is the output when the command is run using Azure Cloud Shell with Bash:
96
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Public Internet
Public
sqlhyperscalerevealed01. endpoint
database.windows.net
Hyperscale
Firewall
Database
There are several different types of network access rules that can be applied in
combination to the public endpoint.
• Virtual networks: VNets allow you to block traffic that does not
originate from one or more subnets from one or more Azure
VNet. Each Azure VNet must have the Microsoft.Sql service
connection enabled on it. Figure 3-14 shows the conceptual
architecture when a VNet access control is applied.
97
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Public Internet
sqlhyperscalerevealed01. Public
database.windows.net endpoint
Firewall
Hyperscale
Database
Service Connection
• Firewall rules: This allows you to define IP address ranges that are
granted access.
Tip If you’re trying to access the logical server from your machine using a tool
like SQL Server Management Studio (SSMS), then you’ll need to add your client IP
address to this list. Otherwise, your client will be denied access. Be sure to remove
your client IP address once you’ve completed your work.
• Allow Azure services and resources to access this server: This setting
allows any service or resource running in Azure to access this service.
This includes services run by other Azure customers. In general, this
is not a good idea as it grants too much access to the logical server.
98
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Figure 3-15 shows the Networking blade in the Azure Portal that is seen when
configuring public access controls on a logical server.
99
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Tip Azure provides a more extensive set of DDoS features as part of the Azure
DDoS Standard product. However, this needs to be enabled on a VNet, so it cannot
be enabled on the public endpoint.
• Firewall rules and VNet service endpoints: This allows you to filter
traffic to the server based on the originating IP address range or from
specific Azure VNets.
Traffic traveling to this endpoint will travel over the public Internet, unless it
originates from within Azure. If your security or compliance requirements require that
your database traffic does not traverse the public Internet, then you should not use a
public endpoint.
Important If the traffic to your public endpoint originates from within the Azure
network, then it will not leave Azure, but rather it will travel over private Azure
private backbone network infrastructure.
Private Endpoints
Private endpoints allow your logical server (and therefore Hyperscale database) to have
a private IP address within an Azure VNet. This allows you to ensure that your database
traffic never leaves your virtual network environment and doesn’t traverse a public
network. This is often required for sensitive workloads or workloads that must meet strict
compliance requirements.
A single logical server can have private endpoints in multiple VNets.
100
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Enabling a private endpoint for a logical server requires the use of a number of
additional Azure resources.
• Private DNS zone: This is a DNS zone that is assigned to the Azure
VNet to allow a private FQDN name to be used to access the logical
server within the VNet. The zone will usually be automatically
configured as privatelink.database.windows.net for logical
servers in the Azure public cloud.
If there are multiple logical servers with private endpoints in a single VNet,
only one private DNS zone with the name privatelink.database.windows.
net will be created.
The private DNS zone will contain a single DNS A record for each logical
server connected to the VNet and will have the private IP address assigned to
the network interface.
• Private endpoint: This is the resource that governs the other resources
and ties them all together. You can use this resource to configure the
DNS and Application Security group settings, as well as visualize the
private endpoint and its dependencies. Figure 3-16 shows the private
endpoint’s Insights blade to show the dependency view.
101
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
These resources are automatically provisioned for you when you configure this in
the Azure Portal, but if you’re deploying your logical server and the connectivity to it via
infrastructure as code (IaC), then you need to ensure your code does it. We will provide
more detail on deploying a Hyperscale database using IaC in Chapters 9 to 11.
Tip The private endpoint technology that enables the private endpoint in the
VNet is known as Azure Private Link. You can read more about private links at
https://learn.microsoft.com/azure/private-link/private-link-
overview.
102
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Outbound Networking
By default, Azure SQL Database instances in your logical server have no restrictions
on their outbound network connectivity. However, in some scenarios, you may want
to restrict the outbound connectivity of your Hyperscale database to only be allowed
to connect to specific fully domain names. You can configure a list of allowed domain
names that the databases in the logical server can connect to. Figure 3-17 shows
configuring outbound networking restrictions in the Networking blade of the SQL server
resource in the Azure Portal.
Connection Policy
When a client connects to the Azure SQL Database, there are actually two different
methods that can be used to form the connection.
103
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
• Proxy: The client connects to the Azure SQL Database gateway, and
the connection is proxied through to the database cluster hosting
the Azure SQL Hyperscale database. This is the default connection
policy for connections originating outside Azure. This connection
method results in slightly higher latency and a minor reduction in
throughput.
Figure 3-18 shows a logical architecture of the Azure SQL Database gateway and the
default connectivity methods for connections from inside and outside of Azure.
104
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Public Internet
Proxy
Gateway
Client
outside Azure Proxy
Gateway
In general, the redirect policy is preferred because of its lower latency and increased
throughput, but it means that your connection will need to be allowed to connect
to almost any IP address in Azure. This may not be possible from an on-premises
environment or another cloud environment where the network administrator wants to
limit the outbound connectivity to a limited known list of IP addresses. When a proxy
connectivity policy is used, the list of possible IP addresses that a client will need to
connect to is limited to only a few within each region.
105
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Tip The Azure SQL Database gateway is not something you deploy or manage.
It is a highly available, resilient, and scalable service within each region. Each
regional gateway has a limited list of IP addresses that are assigned, making it
easier to whitelist these on a firewall when using Proxy mode. You will not have
any visibility or control over it; it is simply there to manage your connectivity.
However, it is important to understand that it exists and how it affects latency.
You can find a list of the Azure SQL Database gateway IP addresses at https://
learn.microsoft.com/azure/azure-sql/database/connectivity-
architecture.
It is possible to override the default connection policy behavior and force all
connections to use one method, either redirect or proxy regardless of whether the
connection originates from within Azure. However, if you force connections to always
use proxy mode, then you should expect a performance impact from the higher latency
and lower throughput.
Connection Encryption
Azure SQL Database logical servers support in-transit encryption using Transport Layer
Security (TLS). The minimum allowed version at the time of writing this is 1.2, but 1.0
and 1.1 can be enabled, but this is not recommended as they are considered less secure.
Figure 3-19 shows the configuration of encryption in transit settings on a logical server.
If a client tries to connect using a TLS version that is below what is allowed by your
logical server, they will receive an error.
106
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Clients that do not support or require an encrypted connection can still connect, but
in this case, it is recommended to not set a minimum TLS version.
• Your application tier may connect via a public endpoint that requires
the use of a service connection in an Azure VNet subnet.
107
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
• Do any of your database clients require older TLS protocols such as TLS 1.1?
• Do you need to connect to the database via the public Internet from
an on-premises environment where the network administrator
requires IP whitelisting the addresses?
Being able to articulate requirements within these considerations will help you
define the required network connectivity to your Hyperscale database.
108
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Authentication
Authentication is the process of verifying the identity of the user (or service) that the
client is using to connect to the logical server. During the login process, the logical server
will verify the provided credentials with a directory service.
• SQL login only: User account details, including credentials, are stored
in the Azure SQL database. An administrator SQL login is specified
when the logical server is created and will be granted the db_owner
role in each user database.
109
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Tip If you are using replication with either a geo replica or named replica
(covered later in this chapter), then you will need to configure the same SQL
authentication methods and have sufficient permissions on both the primary and
on the replica logical servers.
Figure 3-20 shows the Azure Active Directory blade for the logical server in the Azure
Portal being configured to support only Azure AD authentication. An Azure AD group
called SQL Administrators has been defined as the admin.
110
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
There are many benefits to using Azure AD authentication in your logical server.
111
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Tip For more information on using Azure AD authentication with your logical
server database, please see https://learn.microsoft.com/azure/azure-
sql/database/authentication-aad-overview.
Figure 3-21 shows the results of a Microsoft Defender for SQL vulnerability
assessment running against a logical server deployed from the examples in
this book.
112
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
113
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Figure 3-23 shows the Identity blade in the Azure Portal for a logical server, with
a single user-managed identity assigned. A system managed identity can also be
assigned here.
Managed identities in Azure can be granted RBAC roles just like any other identity.
This gives the logical server and the databases it contains the same access to Azure as
the identity that is being used has. The support for multiple UMIs within a single logical
server allows you to reduce the scope of each UMI to only the roles needed.
115
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Tip There are also several other benefits to using customer-managed keys.
For more information, see https://learn.microsoft.com/en-us/azure/
azure-sql/database/transparent-data-encryption-byok-overview.
Tip If your Azure Key Vault is configured to use Azure RBAC, then you can simply
grant the logical server identity the Key Vault Crypto Service Encryption User role.
• If you are using the firewall with Azure Key Vault, then you
must enable the “Allow trusted Microsoft services to bypass the
firewall” option.
116
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Once the customer-managed key has been set, the databases will be updated to use
it. Figure 3-24 shows a logical server configured to use a customer-managed key in an
Azure Key Vault.
Ledger
The ledger feature of Azure SQL Database helps establish trust around the integrity of
data stored in the database by providing tamper-evidence capabilities in your database.
Figure 3-25 shows the Security step in the creation of an Azure SQL Database
instance with the ledger configuration section highlighted.
117
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Configuring a ledger will require you to specify an Azure Storage account or an Azure
Confidential Ledger (in preview at the time of writing) to store the generated digests.
Otherwise, you can manually generate the digests and store them in your own location.
Figure 3-26 shows the configuration settings for storing the ledger digests.
118
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Once the database has been deployed, the ledger digest storage can be changed by
going to the Ledger blade in the SQL Database instance.
119
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
In this section, we’ll look at how we can monitor our Hyperscale database.
Diagnostic Settings
Every Azure SQL Database instance (including the Hyperscale tier) continuously
produces diagnostic logs and performance metrics. To retain these logs so that
diagnostics, audit, and performance analysis can be performed on the database, they
need to be streamed to an external storage service. The recommended service for this is
an Azure Log Analytics workspace.
Azure Log Analytics is part of the Azure Monitor suite of tools. It provides a single
storage and analytics platform to ingest, analyze, and visualize diagnostics and
performance metrics from one or more resources within Azure.
When planning for monitoring of your Hyperscale database, you need to consider
the following:
• Retention period: How long do you need to retain the diagnostic and
audit logs for the Hyperscale database? By default, data is retained
for 31 days in an Azure Log Analytics workspace. But you may need
to increase this for compliance or business reasons. Increasing the
retention period of diagnostic information will increase the cost.
Tip You can control the retention period for each diagnostic source to help you
manage costs in a more granular fashion.
120
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
counters. Collecting all these records will increase the cost of your log
analytics workspace. Determining the diagnostic information that is
important to your business is important to controlling costs.
Each Azure SQL Database that should send data to a Log Analytics workspace needs
to have Diagnostic Settings configured. Figure 3-27 shows the Diagnostic setting for an
Azure SQL Hyperscale database in the Azure Portal. It shows all diagnostic categories
and metrics being set to a Log Analytics workspace called sqlhyperscalerevealed-law
in East US (the same region as the Hyperscale database).
121
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
• Azure Event Hub: Use this to send the audit logs to an external system.
You can also choose to enable auditing of Microsoft support operations, which will
capture Microsoft support engineers’ (DevOps) operations.
Tip For more information on Auditing for Azure SQL Database, see this
page: https://learn.microsoft.com/azure/azure-sql/database/
auditing-overview.
Figure 3-28 shows the audit configuration on a logical server to send database events
to a Log Analytics workspace.
122
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
The main consideration for this is the cost of ingesting and retaining the audit
data that is generated by the database. Sending this data out of the region will incur an
additional traffic cost.
123
Chapter 3 Planning an Azure SQL DB Hyperscale Environment
Summary
As you can see, there are a number of factors we need to consider when planning an
Azure SQL Database Hyperscale deployment. Some of these factors are similar to
deploying any other Azure SQL Database instance, but others have considerations
specific to the Hyperscale architecture. Understanding these differences and being clear
on the requirements of the solution are key to ensuring a successful architecture that
meets or exceeds business objectives.
In the next chapter, we will design a Hyperscale environment that will satisfy a
set of functional and nonfunctional requirements, such as restricting network access,
configuring high availability and disaster recovery, and enabling encryption of the
database with our own keys. Once we have defined the architecture that will satisfy
the requirements, we will deploy a starting environment and then build up our new
Hyperscale environment step-by-step over the following five chapters, providing
guidance on each feature.
124
CHAPTER 4
Deploying a Highly
Available Hyperscale
Database into a Virtual
Network
In Chapter 3, we looked at some of the key design decisions that we need to make
when deploying Azure SQL DB Hyperscale into our environment. This also gave us the
opportunity to identify and examine some of the key features of Hyperscale in more
detail. In this chapter and Chapters 5 to 8, we’re going to demonstrate these key features
of Hyperscale by deploying a more comprehensive example into an Azure environment.
This environment will be representative of how a Hyperscale database will usually be
deployed in production. You can also perform the steps described in the following
chapters in your own Azure subscription to configure the same environment.
Tip In this chapter, we’ll be sharing several scripts. These will all be available
in the ch4 folder in the source files accompanying this book and also in this
GitHub repository: https://github.com/Apress/Azure-SQLHyperscale-
Revealed.
125
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_4
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Most environments are likely to contain more than just the Hyperscale database.
There are usually Azure resources that need to be available to support the Hyperscale
database in an environment, such as Azure VNets, Key Vaults, and Log Analytics
workspaces. These services are common to most environments in Azure so are likely
already in place. But, for the examples in these chapters, we will deploy them by using a
script and call it our starting environment.
We will then go through the steps to deploy and configure the Hyperscale database
using the Azure Portal. Once the Hyperscale database is deployed, the next four chapters
will demonstrate how to update the configuration to make use of additional features and
how to manage a Hyperscale database once it is put into a virtual network.
Important Almost every subnet in a virtual network will contain Azure network
security groups to control the flow of traffic between the Internet, the virtual
networks, and the resources connected to it. This is beyond the scope of this book,
but it is best practice to restrict traffic within your virtual networks using network
security groups. For more information on network security groups, see https://
aka.ms/networksecuritygroups.
126
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Tip A service level objective (SLO), recovery time objective (RTO), and recovery
point objective (RPO) would normally be defined as part of the nonfunctional
requirements.
127
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Figure 4-1 shows a diagram of the architecture we will be deploying throughout this
chapter. This architecture satisfies the previous requirements.
Async replication
Replica Replica Primary Failover
Hyperscale Hyperscale Hyperscale Hyperscale
Database Database Database Database
Private Private
Application Tier Application Tier
Endpoint Endpoint
App subnet Data subnet Data subnet App subnet
Application Network Private DNS Zone Private DNS Zone Network Application
Security Group Security Group Security Group Security Group
128
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Important The Azure resources that will be deployed to your subscription will
cost money to run (unless you’ve got credit on your subscription). If this is for the
purposes of learning, then you should take care to dispose of your environment
after completing any exercises to minimize cost. Instructions for cleaning up the
environment are provided at the end of this chapter, as well as a simple script you
can use.
You do not need to follow along with these examples to gain value from them,
but doing so will provide you with more practical experience with Azure and
Azure SQL Hyperscale.
129
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
These services are still needed for our Hyperscale database, but we’ll deploy them
via a PowerShell script (using Azure Cloud Shell) to simplify the process. The following
are the supporting services that we will deploy via a script:
• Resource groups: The Azure resource groups that will contain the
supporting services. The resource group in the primary region will be
called sqlhr01-rg and the failover region sqlhr02-rg. These aren’t
shown on the architecture diagram for the sake of simplicity.
• Azure virtual networks: The primary region sqlhr01-vnet and the
failover region sqlhr02-vnet. The subnets App and Data will also be
created. The virtual networks are required to host the application tier
as well as the private endpoints for the logical servers.
• Azure Key Vault: This will be used to store the customer managed
key for TDE on the Hyperscale database. The Azure Key Vault is
called sqlhr. Azure Key Vaults are automatically replicated to the
paired region.
Important It is recommended that you deploy a second Key Vault into the
failover region when using customer-managed TDE, even though Azure Key Vault is
geo-replicated.
We will also use the Azure East US as the primary region and West US 3 as the
failover region. However, if you’re following along with the examples, you can choose
whichever regional pair you choose, from the list on this page: https://learn.
microsoft.com/azure/reliability/cross-region-replication-azure#azure-cross-
region-replication-pairings-for-all-geographies.
The virtual machine scale set in the application tier won’t be deployed as part of
the example. It is just shown for reference and to demonstrate how we might architect a
multitier application using Azure SQL DB Hyperscale.
Figure 4-2 shows a diagram of the starting environment.
130
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Tip The scripts and other files accompanying this book can be found in the
GitHub repository: https://github.com/Apress/Azure-SQL-Hyperscale-
Revealed.
131
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
The script accepts a few parameters that allow you to customize the environment for
your needs.
To ensure the resource names are all unique, the script will suffix a four-character
string into each resource name to reduce the chance that we will have a conflict.
However, even with the suffix, name conflicts are still not impossible, so be on the
lookout for error messages that indicate a name conflict has occurred.
The New-SQLHyperscaleRevealedStartingEnvironment.ps1 script deploys
the environment using Azure Bicep, so it can be run multiple times as long as
you have specified ResourceNameSuffix to the same value each time. If you
have allowed the script to randomly generate a resource name suffix by setting
UseRandomResourceNameSuffix, then each time you run the script, it will create a new
environment.
132
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Tip If you’re not familiar with Azure Cloud Shell or would like to know more about
it, see https://aka.ms/CloudShell.
We are going to use PowerShell in Azure Cloud Shell for this process, because the
New-SQLHyperscaleRevealedStartingEnvironment.ps1 is written in PowerShell.
To create the starting environment, follow these steps:
1. Open your browser and navigate to https://portal.azure.com.
2. Open the Azure Cloud Shell by clicking the Cloud Shell button.
Tip If you would like a full-screen Azure Cloud Shell experience, you can navigate
to https://shell.azure.com.
133
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
4. Clone the GitHub repository that contains the source code for this
book by running the following command:
./Azure-SQL-Hyperscale-Revealed/ch4/New-SQLHyperscaleReveale
dStartingEnvironment.ps1 -ResourceNameSuffix '<your resource
name suffix>'
7. It will take a few minutes to run but will eventually produce output
like Figure 4-3, showing partial output from creating the starting
environment, including a list of resources that were created.
134
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
9. In the “Filter for any” field box, enter shr. This will show the
resource groups that were created for the starting environment, as
shown in Figure 4-4.
10. You can click into one of the resource groups to see the resources
that were created.
Your starting environment is now ready for you to begin deploying the Hyperscale
resources into it. If at any time you want to get rid of this environment, see the
instructions at the end of this chapter, or simply delete the two resource groups. You can
always re-create the starting environment again by running the script.
135
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Tip It is not possible to assign more than one user to be the SQL administrator of
a logical server; therefore, if you want to enable more than one, you must create a
security group with members consisting of the users you want to be admins and
assign this group instead.
If you’re familiar with the process of creating security groups in Azure Active
Directory, then you should find this very straightforward.
136
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
137
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
138
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
You can now assign this security group as the SQL administrator for your logical
servers.
139
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
We will be using a service called Azure Private Link. This will add our logical server
to a subnet in the virtual network using a virtual network adapter and make it available
as a private endpoint. The virtual network adapter will be assigned a private IP address
within the subnet, and a DNS A record will also be created in an Azure DNS zone. The
Azure DNS zone will be added to the virtual network as a DNS resolver.
Tip The Azure Private Link service allows many different resources to be
attached to a virtual network. For more information on Private Link, see this page:
https://aka.ms/privatelink.
Although all the previous tasks sound complicated, they are straightforward to
perform when using the Azure Portal. The deployment process for an Azure SQL
Database and the private endpoint takes care of most of the work for you. However, if
you’re deploying the logical server and Hyperscale database using code, then you will
need to deploy the additional private endpoint components individually as part of your
code, which we’ll show in Chapters 9, 10 and 11.
The integration of a logical server into a virtual network using a private endpoint can
be done either at the time of deploying the logical server or after deployment has been
completed. The Networking blade of the SQL Server resource (the logical server) can be
used to add an existing logical server into one or more virtual networks but will instead
use the Azure Private Link user interface.
Tip It is possible to have a single logical server attached to multiple Azure virtual
networks. This can be useful if your Hyperscale database needs to be accessed by
multiple applications that are deployed into separate disjointed virtual networks.
We are also going to enable high-availability replicas across availability zones in the
primary region. This will ensure at least two read replicas of our primary Hyperscale
database are available within the primary region, each in a different availability
zone. This will protect our workload against failure of one or two availability zones in
the region. Just like the virtual network connectivity with private endpoint, you can
configure the high-availability replicas during deployment or after they are complete.
For now, we will deploy the high-availability replicas during deployment.
140
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Note The following steps are like those we saw in Chapter 1 when deploying
our first Hyperscale database. Therefore, to increase brevity, we are going to omit
some of the screenshots that you’ll already have seen if running through the steps
in that chapter. It is also quite common for the user interface for this process to
change slightly as new features are added. So, what you see might slightly differ
but should still be similar enough for you to follow along.
Finally, during the deployment, we will also configure the logical server to use
only Azure Active Directory (Azure AD) authentication and set the admin as the SQL
Administrators group.
Deploying the logical server and Hyperscale database and connect them to the
virtual network using the Azure Portal will require completing a wizard. This wizard does
have several pages. So, we’ve chosen to break each element of the configuration into its
own section.
5. The Create SQL Database blade will open showing the Basic
configuration options of our database.
6. Make sure the subscription is set to the name of the subscription
you have permission to deploy into and contains the starting
environment we deployed earlier.
141
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
7. Set the resource group to the primary resource group that was
created as part of the starting environment. This will be the
sqlhr01-<suffix>-rg that is in the Azure East US region.
10. Every logical server must have a unique name, not just within
our environment, but globally. For this example, we’re using
sqlhr01-shr8, but you should use a name that is likely to be
globally unique.
11. Set the location to the Azure region to which you want to deploy
the SQL Database Server. This is the primary region where the
logical server will be deployed. All databases contained by this
logical server will also be in this region. We will set this to East US.
142
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
12. Set the authentication method to “Use only Azure Active Directory
(Azure AD) authentication.”
13. Click the “Set admin” button to select the Azure AD user or group
that will be granted the admin role on this SQL Database server.
Select the SQL Administrators group that was created earlier.
143
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
15. Ensure that No is specified for “want to use SQL elastic pool”
because Hyperscale databases can’t be put inside an elastic pool.
Tip You can ignore the workload environment setting because we will always
have to override this when specifying a Hyperscale database.
19. Set the vCores according to your needs. In our case, we’ll use two to
keep costs down, but we can always scale up later. Each secondary
replica will also have this number of vCores assigned to it.
20. Select the number of high-availability secondary replicas to the
number of secondary replicas you want in the region. We’ll set this
to 2 as well. This will mean we have one primary replica and two
secondary replicas.
144
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
21. Specify Yes for the “Would you like to make this database zone
redundant” option.
Note You may have noticed a warning that making the database replicas zone
redundant may change the database backup storage settings. This is because
when you enable this setting, only zone-redundant backup storage is supported.
23. You will return to the Create SQL Database wizard. You may
have noticed that the backup storage redundancy has only two
enabled options: geo-zone-redundant backup storage and
zone-redundant backup storage. We will choose the geo-zone-
redundant backup storage so that our backup is replicated to
another region in the case of a regional outage.
145
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Now that we’ve configured the logical server and the Hyperscale database, we can
move on to the networking page.
147
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Figure 4-5 shows the create private endpoint page with a completed configuration.
148
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
4. Click OK.
149
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Now that we have configured the networking, we can finalize the deployment by
setting any security and additional settings.
150
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
9. Review the settings for your logical server and database and
ensure the costs for running this environment are what you
expect. Figure 4-6 shows an example of the summary of costs that
are displayed on the settings review screen before committing the
deployment.
151
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Tip We could click “download a template for automation,” which will produce a
declarative IaC template that will allow us to re-create this exact deployment.
152
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
This completes the deployment of the new logical server connected to the private
network and configured with a two-vCore primary Hyperscale database with two
secondary high-availability replicas, spread across three availability zones in the region.
Our primary region should now look like Figure 4-8.
153
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
Private
Application Tier
Endpoint
App subnet Data subnet
154
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
155
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
We have provided a handy PowerShell script for you to quickly clean up any starting
environments you might have deployed. As before, we are going to use Azure Cloud
Shell to run the script. We are going to use PowerShell in the Azure Cloud Shell for
this process, because Remove-SQLHyperscaleRevealedEnvironment.ps1 is written in
PowerShell.
156
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
2. Open the Azure Cloud Shell by clicking the Cloud Shell button.
3. Ensure PowerShell is selected in the shell selector at the top of the
Cloud Shell.
./Azure-SQL-Hyperscale-Revealed/ch4/Remove-SQLHyperscaleRevealed
Environment.ps1
After a few minutes, the resource groups will be deleted, and you will no longer be
charged for any resources you have deployed as part of the examples in this chapter.
Summary
In this chapter, we demonstrated how to do the following:
157
Chapter 4 Deploying a Highly Available Hyperscale Database into a Virtual Network
In the next chapter, we will look at some of the options we have for connecting to and
managing this Hyperscale database now that it is accessible only from within a virtual
network.
158
CHAPTER 5
Administering a
Hyperscale Database in
a Virtual Network in the
Azure Portal
In Chapter 4, we deployed a logical server with a Hyperscale database and connected it
to a virtual network using a private endpoint. The logical server’s public endpoint was
disabled. This is a common design pattern that is used to allow access to the database
only from resources connected to the virtual network infrastructure and to ensure all
traffic to and from the logical server travels from the virtual network via the private
endpoint.
However, when we have a logical server connected to a virtual network using a
private endpoint and have disabled the public endpoint, then we will need to consider
how database administrators (DBAs) will connect to the Hyperscale database to perform
management tasks.
In this chapter, we will list some of the common ways DBAs can connect to the
Hyperscale database in a virtual network. We will also demonstrate a simple and
secure approach to enabling management when another, more complex networking
infrastructure connects your management machines to the virtual network.
159
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_5
Chapter 5 Administering a Hyperscale Database in a Virtual Network in the Azure Portal
The Hyperscale database that we deployed in Chapter 4 was attached to the data_
subnet in the sqlhr01-<prefix>-vnet virtual network in the primary region. We also
disabled public access to the database. This means it is accessible only from services that
are within the virtual network or peered networks and there aren’t any network security
groups that block access to it.
If we try to connect to the database from within the SQL Database query editor from
within the Azure Portal, we will receive an error message telling us that to connect we
will need to use the private endpoint from within the virtual network. Figure 5-1 shows
the error message that is received if you try to connect to the database from outside the
virtual network without using the private endpoint.
160
Chapter 5 Administering a Hyperscale Database in a Virtual Network in the Azure Portal
This won’t be a problem for our application tier because it will be deployed into the
app_subnet within the same virtual network and can use the private endpoint to connect
to the database. But how would we go about administering the Hyperscale database
from outside that network?
There are many ways database administrators can still connect to the database, but
some of the most common approaches are the following:
161
Chapter 5 Administering a Hyperscale Database in a Virtual Network in the Azure Portal
The best method for your environment will depend on how your networking is
configured and the type of controls your technology and security teams place on it. For
162
Chapter 5 Administering a Hyperscale Database in a Virtual Network in the Azure Portal
the remainder of this chapter, we will be using the management VM with Azure Bastion.
This is a good method to use if you can’t connect your own management machine
directly to the virtual network that contains the private endpoint to your logical server.
Figure 5-3 shows the list of subnets after deploying the new subnet.
163
Chapter 5 Administering a Hyperscale Database in a Virtual Network in the Azure Portal
164
Chapter 5 Administering a Hyperscale Database in a Virtual Network in the Azure Portal
We will leave the remaining VM configuration up to you, but you could consider
enabling an auto-shutdown policy to reduce costs when the management VM is not in
use. You should also enable automatic guest OS patching if possible.
Next, we need to create an Azure Bastion that can be used to access the management
VM. To create this in the Azure Portal, follow these steps:
1. Create a new Azure Bastion service by selecting “Create a
resource” in the Azure Portal and locating the Azure Bastion
listing.
165
Chapter 5 Administering a Hyperscale Database in a Virtual Network in the Azure Portal
Once the management VM and the Azure Bastion has been deployed, we will have
a way to connect to the Hyperscale database safely and securely from outside the virtual
network.
166
Chapter 5 Administering a Hyperscale Database in a Virtual Network in the Azure Portal
2. Select Bastion from the Connect drop-down list (see Figure 5-8).
167
Chapter 5 Administering a Hyperscale Database in a Virtual Network in the Azure Portal
5. Click Connect. After a few seconds you will be logged into the
management VM.
Tip Depending on how you’ve configured and connected your Azure VNets, you
could use the same management VM and Azure Bastion instance to manage Azure
SQL Database instances in other virtual networks. However, it is important to
consider what may happen in a regional outage if your management VM and Azure
Bastion instance is deployed to the region that is unavailable.
168
Chapter 5 Administering a Hyperscale Database in a Virtual Network in the Azure Portal
Figure 5-9. Connecting to the Hyperscale database using the public FQDN
169
Chapter 5 Administering a Hyperscale Database in a Virtual Network in the Azure Portal
Now that we have confirmed we can connect to the Hyperscale database from within
a management VM connected to the private network, we can continue to configure the
Hyperscale database to meet the requirements defined in Chapter 3.
Summary
In this chapter, we learned how to enable the management of the logical server and
Hyperscale database when it is accessible only from within an Azure VNet on a private
endpoint. We enabled this by doing the following:
• Creating subnets for the Azure Bastion and the management virtual
machine in the virtual network that the logical server is connected to
In the next chapter, we will configure transparent data encryption to use our own
encryption key.
170
CHAPTER 6
Configuring Transparent
Data Encryption to Bring
Your Own Key
In the previous two chapters, we deployed a Hyperscale database into a virtual network
using a private endpoint and learned how to manage it using a management VM and
Azure Bastion. In this chapter, we will continue to satisfy the nonfunctional requirements
laid out in Chapter 4, by configuring transparent data encryption to use a key managed
by our organization.
There are many reasons why we might choose to manage our own encryption key,
but some of the most common reasons are the following:
But, whatever your reasons for needing to manage your own encryption key, this
chapter will show you how.
171
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_6
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
The Key Vault you choose to use to store the key must have soft-delete and purge
protection features enabled. This is to prevent data loss due to accidental deletion of the
Key Vault or key. The Key Vault and the Hyperscale database must belong to the same
Azure Active Directory tenant, because cross-tenant authorization is not supported.
Tip Even if the soft-delete and purge protection features are enabled on the Key
Vault, it is still recommended that you back up the key. You should also put a delete
lock on the Key Vault. For more information on backing up a key, see https://
docs.microsoft.com/azure/key-vault/general/backup.
172
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
The steps in this chapter assume that your Key Vault is configured to use Azure
role-based access control rather than the older vault access policy. If you are using a Key
Vault that is configured to use vault access policy, then you can still enable customer-
managed TDE, but you’ll need to assign access policies to the Key Vault.
To enable a customer-managed TDE, we will need to perform the following tasks:
• Grant yourself the Key Vault Crypto Officer role-based access control
(RBAC) role on the Azure Key Vault so that you can generate or
import the key to be used as the TDE protector.
• Generate or import a key in the Azure Key Vault in the primary region
sqlhr-<suffix>-kv to be used as the TDE protector. There isn’t a
Key Vault in the failover region because it has a built-in geo replica.
However, best practice for a production environment is to create a
failover Key Vault and back up the key to it.
173
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
• Select the key we generate in the Key Vault to use for transparent data
encryption in the logical server and enable customer-managed TDE.
174
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
5. Click Next.
After a few moments, the deployment will start and should take only a few seconds to
create the user-assigned managed identity.
175
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
Tip Once the configuration of the TDE protector has been completed on both the
primary and failover logical servers, you will not require this RBAC role, except if
you must perform some other tasks on the key. Therefore, you should remove this
RBAC role from your account once the TDE configuration process is complete and
the key has been assigned to the logical server. It is strongly recommended to use
Azure AD Privileged Identity Management to perform a temporary elevation of your
user account to this RBAC role, which will provide even greater assurance and
protection to your key and Key Vault. See https://aka.ms/aadpim for more
information on this using role elevation.
176
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
Now that we have permissions on the Key Vault, we can go ahead and generate or
import the key.
177
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
8. Make sure Enabled is set to Yes. Disabling the key will prevent it
from being used by the logical server.
178
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
11. After the new key has been generated, click it.
179
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
Now that the key has been generated, we will need to grant access to it by the user-
assigned managed identity.
Note These instructions assume that the Key Vault is configured in Azure role-
based access control mode. You can use vault access policy mode if you want,
but you will need to create a policy to grant the identity get, wrapKey, and
unwrapKey permissions. It is recommended to use Azure role-based access
control mode if possible.
3. Click the key that we generated to use as the TDE protector. This
will open the overview for the key.
180
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
6. Select the Key Vault Crypto Service Encryption User role and
click Next.
181
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
Note Any Azure service that is assigned to use this managed identity will be able
to perform the get, wrap key, and unwrap key operations using this key. Although
the permissions granted do not permit any destructive or export activities, it is
important to be careful to use the identity only with services that should access it.
1. In the Azure Portal, navigate to the logical server (the SQL Server
resource) in the primary region, sqlhr01-<suffix>.
182
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
Once the settings have been updated, we can now perform the final task, which is to
enable the customer-managed transparent data encryption.
183
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
1. In the Azure Portal, navigate to the logical server (the SQL Server
resource) in the primary region, sqlhr01-<suffix>. You should
already be here if you’ve performed the previous steps.
4. Click the “Change key” button. The “Select a key” form will
be shown.
6. Specify the Key Vault with our key. In our case, it’s sqlhr-
<suffix>-kv.
7. Set the key to the key we generated in the Key Vault. It was called
sqlhr-shr8-tdeprotector.
8. We don’t need to specify a version of the key to use; just use the
current version.
10. Select the “Make this key the default TDE protector” box.
Figure 6-5 shows the transparent data encryption configuration
after we’ve enabled a customer-managed key.
11. If you enabled automatic key rotation policy on the TDE protector
key in the Key Vault or if you’re planning on manually rotating the
key, select the “Auto-rotate key”. Figure 6-5 shows how to configure
the customer-managed TDE key to retrieve it from a Key Vault.
184
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
13. After a few seconds, we will receive confirmation that the settings
have changed.
We have now successfully configured our Hyperscale database to use a key that we
manage for TDE. This may help us meet certain compliance requirements or centralize
the management and monitor the use of TDE protectors, but it does increase the work
we need to do to deploy and operate the service.
Summary
By default, all data is encrypted at rest in Azure SQL Database instances, including
Hyperscale. This includes the data files, the log files, and the backups. These are
normally encrypted by a key, called the TDE protector, that the service manages. In
this chapter, we learned how to configure a customer-managed key to use as the TDE
protector for encryption.
185
Chapter 6 Configuring Transparent Data Encryption to Bring Your Own Key
• Add the Key Vault Crypto Service Encryption User role to the user-
assigned managed identity for the key protector
186
CHAPTER 7
Enabling Geo-replication
for Disaster Recovery
In the previous few chapters, we defined a comprehensive set of nonfunctional
requirements for a Hyperscale database environment and then set about deploying it.
This included creating the starting environment, deploying the Hyperscale database into
the virtual network using a private endpoint, and enabling transparent data encryption
with a customer-managed key. We also took a look at how DBAs can manage the
Hyperscale database from within the virtual network.
In this chapter, we will demonstrate how to configure the environment to continue
to function in case the primary region is inaccessible. To meet this requirement, we will
enable a geo replica of our primary Hyperscale database in a region we call the failover
region (also sometimes called the secondary region). The failover region will often be the
Azure region that is paired with the primary region, but in some cases it may need to be a
different region.
There are several reasons for not selecting the Azure paired region for your
failover region.
• There is no paired region. For example, Brazil South does not
currently have a paired region so is usually paired with a US region.
• The paired region does not support the features you require. For
example, if you require Hyperscale high-availability replicas with
availability zone support and the paired region is not availability zone
enabled.
187
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_7
Chapter 7 Enabling Geo-replication for Disaster Recovery
Tip Hyperscale also supports named replicas. These are like high-availability
replicas in that they share the same page servers as the primary replica. This
means there is no need to synchronize data to the named replica but also means
they can be placed only in the same region as the primary replica. They can be
connected to the same logical server as the primary replica but will need to have a
different database name. Alternatively, they can be connected to a different logical
server in the primary region, in which case they can have the same database
name. The main purpose of these is to enable read scale-out and to prevent read
interruption if the primary replica is scaled up or down.
Important If the logical server in the failover region will use a different Key Vault
to store the TDE protector than that of the logical server in the primary region, then
the key will need to be copied into the failover Key Vault. A process to keep the key
synchronized between the primary and the failover Key Vault will need to be set up.
188
Chapter 7 Enabling Geo-replication for Disaster Recovery
5. Set the resource group to the one created in the failover region.
It should be sqlhr02-<suffix>-rg. Enter sqlhr02-<suffix> for
the server’s name. The location should be set to the region we
189
Chapter 7 Enabling Geo-replication for Disaster Recovery
selected for our failover region, which was West US 3 in our case.
Configure the Authentication method and set the Azure AD admin
just as we did for the primary logical server. Figure 7-1 shows an
example of how the configuration of the failover logical server
will look.
190
Chapter 7 Enabling Geo-replication for Disaster Recovery
8. You might add an Environment tag with the value SQL Hyperscale
Revealed demo so that you can more easily track the costs of this
demonstration environment. Click Next.
9. Review the final settings for the logical server and click Create.
After a few minutes, the new logical server in the failover region will be deployed,
and we can connect it to the virtual network.
Tip This is the same process we would use to connect any logical server to a
virtual network, so it is useful to be familiar with it. It is also similar to connecting
any supported Azure service to a virtual network using Azure Private Link.
1. In the Azure Portal, navigate to the logical server (the SQL Server
resource) in the failover region, sqlhr02-<suffix>.
191
Chapter 7 Enabling Geo-replication for Disaster Recovery
4. Click Save.
6. Set the resource group to the resource group where we will put
the private endpoint. In this example, it should be the failover
resource group, sqlhr02-<suffix>-rg.
7. Enter a name for the private endpoint instance. For this example,
sqlhr02-<suffix>-pe will be used. The network interface name
should be set to indicate that it belongs to this private endpoint,
for example, sqlhr02-<suffix>-pe-nic.
8. Set the region to the location of the virtual network that you want
to connect the private endpoint to. In this case, it will be the
failover region, West US 3. Figure 7-2 shows how the basic settings
for the private endpoint should be configured.
192
Chapter 7 Enabling Geo-replication for Disaster Recovery
9. Click Next.
Note Azure Private Link will automatically select the logical server we started
creating this private endpoint from. If we had chosen to create a private endpoint
from elsewhere in the portal, we would need to specify the target resource
manually.
12. Set the virtual network to the subnet in the virtual network you
want to connect the logical server to. In this case, it is the data_
subnet in the failover virtual network sqlhr02-<suffix>-vnet.
193
Chapter 7 Enabling Geo-replication for Disaster Recovery
15. Ensure “Integration with private DNS zone” is set to Yes so that a
private DNS zone is created within the resource group containing
the private link. This will also associate the DNS zone with the
virtual network. In this case, it should be in the failover resource
group sqlhr02-<suffix>-rg. You may notice that a new private
DNS zone called privatelink.database.windows.net is created
within the same resource group. If one with that name already
exists in the resource group, then a new one won’t be created.
194
Chapter 7 Enabling Geo-replication for Disaster Recovery
16. Enter any tags to assign to these resources and click Next.
18. After a few seconds, the deployment will start and should be
completed within a minute or two. Once it is completed, you
will see three new resources deployed to your resource group.
Figure 7-4 shows the resources that make up the private endpoint
for the logical server.
195
Chapter 7 Enabling Geo-replication for Disaster Recovery
The next step to configure this logical server is to enable the customer-managed key
for transparent data encryption.
Important Both the primary and failover logical servers must be accessing the
key from the same Key Vault. They cannot use a different Key Vault with the same
key material.
To simplify the permissions on the Key Vault, we can reuse the user-assigned
managed identity to allow the logical server to retrieve the key. This identity already has
the correct permissions for our needs as they were granted earlier. If we had chosen to
use a different user-assigned managed identity or a system-assigned managed identity,
then we would need to grant the identity permissions to the key in the Key Vault.
This is performed using the same process as was used on the primary logical server.
196
Chapter 7 Enabling Geo-replication for Disaster Recovery
Figure 7-6. The managed identity for the failover logical server
197
Chapter 7 Enabling Geo-replication for Disaster Recovery
Important You will need to have the Key Vault Crypto Officer RBAC role assigned
to your account to perform this task. You may have removed this role previously
as a security measure or implemented a privileged identity management elevation
process to protect it. If you do not have this role, you will receive the error “This
operation is not allowed by RBAC.”
The failover logical server is now configured to use the same TDE protector key from
the same Key Vault as the primary logical server. This is important so that the data from
the primary logical server can be decrypted and used by the failover logical server.
4. Set the server to the failover logical server that was just deployed,
sqlhr02-<suffix>. In our case, it was in West US 3.
198
Chapter 7 Enabling Geo-replication for Disaster Recovery
7. Click Next.
199
Chapter 7 Enabling Geo-replication for Disaster Recovery
Your failover replica is now available, and you can use it as a read replica or execute a
failover to make it your primary database. We will cover business continuity and failovers
in more detail in a later chapter.
Summary
In this chapter, we showed how to configure a geo replica of our Hyperscale database in
another region to protect against regional outages. To do this, we demonstrated how to
do the following:
• We created a new logical server in the failover region with the same
authentication settings as the logical server in the primary region.
200
Chapter 7 Enabling Geo-replication for Disaster Recovery
In the next chapter, we will finish configuring our Hyperscale environment to meet
our nonfunctional requirements by enabling security features with Microsoft Defender
for SQL and sending diagnostic and audit logging to a central logging and monitoring
service, Azure Log Analytics.
201
CHAPTER 8
Configuring Security
Features and Enabling
Diagnostic and Audit
Logs
In Chapter 7, we configured a geo replica of our primary Hyperscale database in another
Azure region to protect our workload against a failure of the primary region. In this
chapter, we will perform the final tasks that we need to do to improve the security and
monitoring of our Hyperscale database. This will help our environment align to the
practices outlined in the security and operational excellence pillars in the Azure Well-
Architected Framework (WAF).
In this chapter, we will perform the following tasks to improve the security and
monitoring of our Hyperscale database:
203
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_8
Chapter 8 Configuring Security Features and Enabling Diagnostic and Audit Logs
Once these remaining tasks have been completed, our Hyperscale database will be
ready to handle our production workloads.
Tip In general, it is simplest and most effective to enable Microsoft Defender for
SQL at the subscription level. This will automatically enable it on any logical server
created in the subscription and ensure the databases in the logical servers are
monitored by default. For more information, see https://docs.microsoft.
com/azure/defender-for-cloud/enable-enhanced-security.
When you enable Microsoft Defender for SQL, an Azure Storage account is created
in the same resource group as your logical server. This storage account is used to store
the SQL vulnerability assessments that are created. You can configure a different storage
account to be used, for example if you want to store all vulnerability assessments for
multiple logical servers in a central location.
The simplest way to enable Microsoft Defender for SQL is to enable it on the logical
server. To do this, follow these steps:
204
Chapter 8 Configuring Security Features and Enabling Diagnostic and Audit Logs
205
Chapter 8 Configuring Security Features and Enabling Diagnostic and Audit Logs
7. Click Save.
Microsoft Defender is now set up to monitor the logical server and any databases
it contains. It will periodically perform vulnerability assessments and store them in the
storage account that was specified.
206
Chapter 8 Configuring Security Features and Enabling Diagnostic and Audit Logs
• An event hub: You would use this to stream the diagnostic and audit
logs as events to another monitoring service.
• A partner solution: You can stream the logs into a third-party solution
that is integrated into Azure. This is available only for diagnostic logs.
You can configure diagnostic logs and audit logs to be sent to a combination of
destination types, but for this example, we are going to send them to a Log Analytics
workspace.
207
Chapter 8 Configuring Security Features and Enabling Diagnostic and Audit Logs
Tip For more information on the Kusto Query Language (KQL), see https://
aka.ms/kql.
There are two ways you can configure the sending of audit logs for a Hyperscale
database.
• The logical server: This will result in all databases associated with this
logical server having audit logs sent to the destination.
Important You should not enable auditing on both the logical server and a
database contained in the logical server unless they are being sent to different
destinations. For example, you should not configure auditing for the logical server
and a database to be sent to the same Log Analytics workspace as this will result
in audit duplicate records being sent. However, you can send them to different Log
Analytics workspaces.
To configure the audit logs for the logical server to the Log Analytics workspace,
perform the following:
4. Set the subscription to the one that contains your Log Analytics
workspace.
208
Chapter 8 Configuring Security Features and Enabling Diagnostic and Audit Logs
7. Click the Save button. After a few seconds you will receive
a confirmation message that your settings have been saved
successfully.
This will also create an SQLAuditing solution in the resource group, associated with
the Log Analytics workspace. This solution provides some audit-specific reporting and
dashboard functionality to help your logical server.
It is also good practice to send the audit logs for the logical server in the failover
region to the Log Analytics workspace in the failover region. So, you should perform the
previous tasks on the replica in the failover region.
209
Chapter 8 Configuring Security Features and Enabling Diagnostic and Audit Logs
5. Select the “Send to Log Analytics workspace” box and select the
subscription and Log Analytics workspace from your primary region.
8. Click the Save button. After a few seconds, you will receive
a confirmation message that your settings have been saved
successfully.
210
Chapter 8 Configuring Security Features and Enabling Diagnostic and Audit Logs
You can configure up to five diagnostic log settings to send different combinations of
logs and metrics to different destinations. It is also a good idea to configure your failover
replica to send diagnostic logs to the Log Analytics workspace in the failover region.
Summary
With these final changes to our logical server and Hyperscale database, we have
successfully created an environment that meets the requirements defined in Chapter 4
by enabling the following:
• The Azure Active Directory identity as the only identity source for our
Hyperscale database
Over the next three chapters, we will demonstrate how to deploy the same
environment, but we’ll be using infrastructure as code with Azure PowerShell, Azure
Command-Line Interface (CLI), and Azure Bicep.
211
CHAPTER 9
Tip In this chapter, we’ll be sharing individual PowerShell code snippets as well
as a complete script that can be used to deploy the environment. These will all
be available in the ch9 directory in the files accompanying this book and in the
GitHub repository: https://github.com/Apress/Azure-SQL-Hyperscale-
Revealed.
213
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_9
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
Note There are many other IaC technologies available that we haven’t included
in this book, simply for brevity. Some other common IaC technologies used with
Azure are Hashicorp Terraform (https://www.terraform.io) and Pulumi
(https://www.pulumi.com), but there are certainly others. If your preferred
technology is not demonstrated, it is just to keep the length of the book down, not
because it is any less important.
Note Although the term infrastructure has traditionally been used to refer to
virtual machines, storage, and networks, when we are talking about infrastructure
in the IaC context, it will refer to any resource that can be deployed into Azure.
Defining your Azure resources with IaC provides you with many benefits.
214
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
There are many other benefits to implementing IaC, and your organization
might implement IaC methodologies that leverage some or all these benefits. But,
fundamentally, IaC is about storing your infrastructure definitions in reusable files.
215
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
In Azure, some of the common declarative technologies are Azure Resource Manager
(ARM) templates, Azure Bicep (which are transpiled to ARM templates), and Hashicorp
Terraform (using the Hashicorp Configuration Language). When using ARM templates
or Azure Bicep, the engine responsible for ensuring the infrastructure is in the desired
state is Azure itself using the Azure Resource Manager. However, with Terraform the state
engine is external to Azure and provided as part of Hashicorp Terraform and Terraform
Azure Resource Provider and relies on maintaining its own internal view of the current
state of the Azure environment.
A discussion about the pros and cons of the different methodologies is beyond
the scope of this book, but it is recommended to move to a declarative methodology
whenever possible.
The remainder of this chapter will be dedicated to demonstrating the deployment
of our Hyperscale environment using PowerShell and the Azure PowerShell modules.
In Chapter 10, we will show the deployment of the same Hyperscale environment
using Bash and the Azure CLI. Rounding out the IaC samples, Chapter 11 will show a
declarative IaC methodology using Azure Bicep to deploy the Hyperscale environment.
216
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
commands are split across different PowerShell modules, each providing commands
relevant to a specific Azure service. However, if you install the main Azure PowerShell
module Az, then all Azure PowerShell modules will be installed.
There are many ways you can install the Azure PowerShell modules into your own
PowerShell environment, but if you’re using Azure Cloud Shell, they are already pre-
installed and connected to your Azure subscriptions for you.
Tip If you want to install the Azure PowerShell modules into your own
environment, see https://learn.microsoft.com/en-us/powershell/
azure/install-az-ps. These modules are compatible with Windows, macOS,
and Linux operating systems, using either PowerShell or Windows PowerShell.
For the remainder of this chapter, we’ll be using the Azure Cloud Shell. At the time
of writing this book, the current version of the main Azure PowerShell module is 9.2.0,
which is the version installed into the Azure Cloud Shell. You should ensure you’ve got at
least this version installed if you’re running the commands and scripts in this chapter.
To check the version of main Azure PowerShell module installed, run the following
PowerShell command:
Figure 9-1 shows the result of running the command to get the main Azure
PowerShell module installed in the Azure Cloud Shell.
To check all the dependent Azure PowerShell modules, run the following PowerShell
command:
217
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
Figure 9-2 shows some of the Azure PowerShell modules installed with the main
Azure PowerShell module.
Now that we have an environment with the Azure PowerShell modules installed and
connected, we can begin the process of deploying the environment.
The script accepts a few parameters that allow you to customize the environment for
your needs.
Note The UPN is required when running the script in the Azure Cloud Shell
because of the way the Azure Cloud Shell executes commands using a service
principal, instead of your user account. In this case, the script can’t automatically
detect your user account to assign appropriate permissions to the Azure Key Vault
during the creation of the TDE protector.
3. Clone the GitHub repository that contains the source code for this
book by running the following command:
219
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
./Azure-SQL-Hyperscale-Revealed/ch9/Install-SQLHyperscale
RevealedHyperscaleEnvironment.ps1 -ResourceNameSuffix '<your
resource name suffix>' -AadUserPrincipalName '<your Azure AD
account UPN>'
Because of the number of resources being created, the deployment process may take
30 minutes or more.
220
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
Figure 9-3 shows the creation of the helper variables in the Azure Cloud Shell.
Note These variables will need to be re-created if your Azure Cloud Shell closes
between running commands.
221
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
$newAzUserAssignedIdentity_parameters = @{
Name = "$baseResourcePrefix-$resourceNameSuffix-umi"
ResourceGroupName = $primaryRegionResourceGroupName
Location = $primaryRegion
Tag = $tags
}
New-AzUserAssignedIdentity @newAzUserAssignedIdentity_parameters
$userAssignedManagedIdentityId = "/subscriptions/$subscriptionId" + `
"/resourcegroups/$primaryRegionResourceGroupName" + `
"/providers/Microsoft.ManagedIdentity" + `
"/userAssignedIdentities/$baseResourcePrefix-$resourceNameSuffix-umi"
Figure 9-4 shows the expected output from the user-assigned managed identity
being created.
222
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
$newAzRoleAssignment_parameters = @{
ObjectId = $userId
RoleDefinitionName = 'Key Vault Crypto Officer'
Scope = "/subscriptions/$subscriptionId" + `
"/resourcegroups/$primaryRegionResourceGroupName" + `
"/providers/Microsoft.KeyVault" + `
"/vaults/$baseResourcePrefix-$resourceNameSuffix-kv"
}
New-AzRoleAssignment @newAzRoleAssignment_parameters
In Figure 9-5 we show example output from assigning the Key Vault Crypto Officer
role to the Key Vault.
223
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
Figure 9-5. Assigning the Key Vault Crypto Officer role to the Key Vault
Once the role has been assigned, the user account can be used to create the TDE
protector key in the Key Vault using the Add-AzKeyVaultKey command and then assign
the identity to a variable (for use when creating the logical server).
$addAzKeyVaultKey_parameters = @{
KeyName = "$baseResourcePrefix-$resourceNameSuffix-tdeprotector"
VaultName = "$baseResourcePrefix-$resourceNameSuffix-kv"
KeyType = 'RSA'
Size = 2048
Destination = 'Software'
Tag = $tags
}
Add-AzKeyVaultKey @addAzKeyVaultKey_parameters
$tdeProtectorKeyId = (Get-AzKeyVaultKey `
-KeyName "$baseResourcePrefix-$resourceNameSuffix-tdeprotector" `
-VaultName "$baseResourcePrefix-$resourceNameSuffix-kv").Id
Figure 9-6 shows the output from creating the TDE protector.
224
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
Figure 9-6. Creating the TDE protector key in the Key Vault
The service principal that is created as part of the user-assigned managed identity
then needs to be granted the Key Vault Crypto Service Encryption User role to the key
that was just created. The New-AzRoleAssignment command is again used for this:
225
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
Figure 9-7 shows sample output from assigning the service principal for a role on the
TDE protector key.
Figure 9-7. Granting access to the TDE protector key to the service principal
The TDE protector key in the Key Vault is now ready to be accessed by the new
logical servers for encryption.
226
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
AssignIdentity = $true
IdentityType = 'UserAssigned'
UserAssignedIdentityId = $userAssignedManagedIdentityId
PrimaryUserAssignedIdentityId = $userAssignedManagedIdentityId
KeyId = $tdeProtectorKeyId
Tag = $tags
}
New-AzSqlServer @newAzSqlServer_parameters
The first line looks up the object ID of the SQL Administrators group in Azure Active
Directory, which is required to be passed to the ExternalAdminSID parameter. The
EnableActiveDirectoryOnlyAuthentication and ExternalAdminName parameters
are also required for the logical server to use Azure AD for authentication. The KeyId
is set to the ID of the TDE protector key, and the UserAssignedIdentityId and
PrimaryUserAssignedIdentityId are set to the resource ID of the user-assigned
managed identity that was granted access to the TDE protector key in the Key Vault.
Figure 9-8 shows part of the output from creating the logical server.
227
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
$sqlServerResourceId = (Get-AzSqlServer `
-ServerName "$primaryRegionPrefix-$resourceNameSuffix" `
-ResourceGroupName $primaryRegionResourceGroupName).ResourceId
$newAzPrivateLinkServiceConnection_parameters = @{
Name = "$primaryRegionPrefix-$resourceNameSuffix-pl"
PrivateLinkServiceId = $sqlServerResourceId
GroupId = 'SqlServer'
}
$privateLinkServiceConnection = New-AzPrivateLinkServiceConnection
@newAzPrivateLinkServiceConnection_parameters
The next step is to use the service connection for the logical server to create a private
endpoint in the virtual network subnet using the New-AzPrivateEndpoint command.
This command requires us to provide the subnet object of the subnet we’re connecting
the private endpoint to.
$vnet = Get-AzVirtualNetwork `
-Name "$primaryRegionPrefix-$resourceNameSuffix-vnet" `
-ResourceGroupName $primaryRegionResourceGroupName
$subnet = Get-AzVirtualNetworkSubnetConfig `
-VirtualNetwork $vnet `
-Name 'data_subnet'
$newAzPrivateEndpoint_parameters = @{
Name = "$primaryRegionPrefix-$resourceNameSuffix-pe"
ResourceGroupName = $primaryRegionResourceGroupName
Location = $primaryRegion
Subnet = $subnet
PrivateLinkServiceConnection = $privateLinkServiceConnection
228
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
Tag = $tags
}
New-AzPrivateEndpoint @newAzPrivateEndpoint_parameters
Figure 9-9 shows part of the output from creating the new private endpoint
connected to the subnet.
Once the private endpoint is created and connected, we need to configure the DNS
entry for it so that it can be resolved correctly from within the virtual network. To do this,
we first create a new private DNS zone with the New-AzPrivateDnsZone command.
$newAzPrivateDnsZone_parameters = @{
Name = $privateZone
ResourceGroupName = $primaryRegionResourceGroupName
}
$privateDnsZone = New-AzPrivateDnsZone @newAzPrivateDnsZone_parameters
This command won’t produce any output but will create the privatelink.
database.windows.net DNS zone in the primary region resource group. The
$privateDnsZone variable will be set to the private zone object and will be used later
when creating the DNS zone record.
229
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
The DNS zone then needs to be connected to the virtual network using the New-
AzPrivateDnsVirtualNetworkLink command. We specify the virtual network ID and the
DNS zone name to connect these two resources.
$newAzPrivateDnsVirtualNetworkLink_parameters = @{
Name = "$primaryRegionPrefix-$resourceNameSuffix-dnslink"
ResourceGroupName = $primaryRegionResourceGroupName
ZoneName = $privateZone
VirtualNetworkId = $vnet.Id
Tag = $tags
}
New-AzPrivateDnsVirtualNetworkLink @newAzPrivateDnsVirtualNetworkLink_
parameters
Figure 9-10 shows the output from connecting the DNS zone to the virtual network.
The final step is to create the DNS record for the logical server in the DNS zone using
the New-AzPrivateDnsZoneConfig and New-AzPrivateDnsZoneGroup commands.
$privateDnsZoneConfig = New-AzPrivateDnsZoneConfig `
-Name $privateZone `
-PrivateDnsZoneId $privateDnsZone.ResourceId
$newAzPrivateDnsZoneGroup_parameters = @{
Name = "$primaryRegionPrefix-$resourceNameSuffix-zonegroup"
230
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
ResourceGroupName = $primaryRegionResourceGroupName
PrivateEndpointName = "$primaryRegionPrefix-$resourceNameSuffix-pe"
PrivateDnsZoneConfig = $privateDnsZoneConfig
}
New-AzPrivateDnsZoneGroup @newAzPrivateDnsZoneGroup_parameters
Figure 9-11 shows partial output from creating the DNS record.
Figure 9-11. Creating the DNS record for the logical server
The logical server is now connected to the virtual network with a private endpoint
and is not accessible on a public IP address.
• ServerName: This is the name of the logical server that the database
will be attached to.
231
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
$newAzSqlDatabase_parameters = @{
DatabaseName = 'hyperscaledb'
ServerName = "$primaryRegionPrefix-$resourceNameSuffix"
ResourceGroupName = $primaryRegionResourceGroupName
Edition = 'Hyperscale'
Vcore = 2
ComputeGeneration = 'Gen5'
ComputeModel = 'Provisioned'
HighAvailabilityReplicaCount = 2
ZoneRedundant = $true
BackupStorageRedundancy = 'GeoZone'
Tags = $tags
}
New-AzSqlDatabase @newAzSqlDatabase_parameters
Figure 9-12 shows part of the output from creating the Hyperscale database using the
New-AzSqlDatabase command. The full output is truncated for brevity.
232
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
$logAnalyticsWorkspaceResourceId = "/subscriptions/$subscriptionId" + `
"/resourcegroups/$primaryRegionResourceGroupName" + `
"/providers/microsoft.operationalinsights" + `
"/workspaces/$primaryRegionPrefix-$resourceNameSuffix-law"
$setAzSqlServerAudit_Parameters = @{
ServerName = "$primaryRegionPrefix-$resourceNameSuffix"
ResourceGroupName = $primaryRegionResourceGroupName
WorkspaceResourceId = $logAnalyticsWorkspaceResourceId
LogAnalyticsTargetState = 'Enabled'
}
Set-AzSqlServerAudit @setAzSqlServerAudit_Parameters
233
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
$logAnalyticsWorkspaceResourceId = "/subscriptions/$subscriptionId" + `
"/resourcegroups/$primaryRegionResourceGroupName" + `
"/providers/microsoft.operationalinsights" + `
"/workspaces/$primaryRegionPrefix-$resourceNameSuffix-law"
$databaseResourceId = (Get-AzSqlDatabase `
-ServerName "$primaryRegionPrefix-$resourceNameSuffix" `
-ResourceGroupName $primaryRegionResourceGroupName `
-DatabaseName 'hyperscaledb').ResourceId
# Get the Diagnostic Settings category names for the Hyperscale database
$log = @()
$categories = Get-AzDiagnosticSettingCategory -ResourceId
$databaseResourceId |
Where-Object -FilterScript { $_.CategoryType -eq 'Logs' }
$categories | ForEach-Object -Process {
$log += New-AzDiagnosticSettingLogSettingsObject -Enabled $true
-Category $_.Name -RetentionPolicyDay 7 -RetentionPolicyEnabled $true
}
$newAzDiagnosticSetting_parameters = @{
ResourceId = $databaseResourceId
Name = "Send all logs to $primaryRegionPrefix-$resourceNameSuffix-law"
WorkspaceId = $logAnalyticsWorkspaceResourceId
Log = $log
}
New-AzDiagnosticSetting @newAzDiagnosticSetting_parameters
234
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
Figure 9-13 shows partial output from configuring the diagnostic settings on the
database.
The deployment and configuration of the Hyperscale database in the primary region
is now complete. We can now deploy the failover region.
Note You can still find the code for this in the Install-SQLHyperscaleRev
ealedHyperscaleEnvironment.ps1 file in the ch9 directory provided in the
source code for this book.
235
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
5. Connect the private DNS zone to the virtual network using the
New-AzPrivateDnsVirtualNetworkLink command.
6. Create the DNS zone group in the private endpoint using the New-
AzPrivateDnsZoneGroup command.
The failover logical server will now be connected to the virtual network, configured
to use customer-managed encryption and to use the SQL Administrators Azure
AD group.
236
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
$newAzSqlDatabaseSecondary = @{
DatabaseName = 'hyperscaledb'
ServerName = "$primaryRegionPrefix-$resourceNameSuffix"
ResourceGroupName = $primaryRegionResourceGroupName
PartnerServerName = "$failoverRegionPrefix-$resourceNameSuffix"
PartnerResourceGroupName = $failoverRegionResourceGroupName
SecondaryType = 'Geo'
SecondaryVCore = 2
SecondaryComputeGeneration = 'Gen5'
HighAvailabilityReplicaCount = 1
ZoneRedundant = $false
AllowConnections = 'All'
}
New-AzSqlDatabaseSecondary @newAzSqlDatabaseSecondary
Figure 9-14 shows the output from running the command to create the geo replica.
237
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
Note You can still find the code for this in the Install-SQLHyperscaleRev
ealedHyperscaleEnvironment.ps1 file in the ch9 directory provided in the
source code for this book.
Remove the Key Vault Crypto Officer Role from the Key Vault
The final task is to remove the Key Vault Crypto Officer role from the Key Vault for the
account running the script. This is simply a security hygiene task that can be performed
by running the Remove-AzRoleAssignment command.
238
Chapter 9 Deploying Azure SQL DB Hyperscale Using PowerShell
$roleAssignmentScope = "/subscriptions/$subscriptionId" + `
"/resourcegroups/$primaryRegionResourceGroupName" + `
"/providers/Microsoft.KeyVault" + `
"/vaults/$baseResourcePrefix-$resourceNameSuffix-kv"
$removeAzRoleAssignment_parameters = @{
ObjectId = $userId
RoleDefinitionName = 'Key Vault Crypto Officer'
Scope = $roleAssignmentScope
}
Remove-AzRoleAssignment @removeAzRoleAssignment_parameters
This command will report a simple success message on deletion of the role:
The Hyperscale architecture that was defined in Chapter 4’s Figure 4-1 has now been
deployed and is ready to use.
Summary
In this chapter, we introduced the concept of infrastructure as code and briefly looked
at the difference between imperative and declarative methods. We demonstrated
the imperative infrastructure as code method of deploying a Hyperscale database
environment using PowerShell and the Azure PowerShell modules. We also described
some of the key Azure PowerShell commands required to deploy the resources.
In the next chapter, we will deploy a similar environment using imperative
infrastructure as code, except using Bash and Azure CLI.
239
CHAPTER 10
Tip In this chapter we’ll be sharing several scripts. These will all be available in the
ch10 folder in the source files accompanying this book and in this GitHub repository:
https://github.com/Apress/Azure-SQL-Hyperscale-Revealed.
241
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_10
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
Table 10-1. Supported Environments for Running Azure CLI and Azure
PowerShell
Operating System Azure PowerShell Azure CLI
242
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
Tip If you want to review instructions for all the different methods of installing
the Azure CLI into your own environment, see https://learn.microsoft.
com/cli/azure/install-azure-cli.
If you’re using Azure Cloud Shell with either Bash or PowerShell, then these
commands are already pre-installed for you. The Azure CLI commands in the Azure
Cloud Shell will also be already connected to your Azure account when you open it.
For the remainder of this chapter, we’re going to be using the Azure CLI in the Azure
Cloud Shell.
The current version of the Azure CLI that is available at the time of writing this book
is v2.41.0. The Azure CLI is updated frequently, so you should ensure that you keep up-
to-date to access the latest features and bug fixes.
Note It is possible that a new feature or bug fix is released for Azure CLI that
breaks your existing scripts, so you should either ensure your automation pins
a specific version or you’re testing and updating your infrastructure as code
regularly. Breaking changes are usually indicated by a major version number
release and may require you to change your code.
243
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
2. Ensure Bash is selected in the shell selector at the top of the Cloud
Shell, as shown in Figure 10-1.
3. Clone the GitHub repository that contains the source code for this
book by running the following command:
./Azure-SQL-Hyperscale-Revealed/ch4/newsqlhyperscalerevealed
startingenvrionment.sh --resource-name-suffix '<your
resource name suffix>'
244
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
It will take a few minutes to deploy the resources but will produce output like
Figure 10-2, showing JSON output from the deployment.
The starting environment is now ready for the remaining Hyperscale resources to be
deployed into it, using Azure CLI commands.
245
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
Note The UPN is required when running the script in Azure Cloud Shell because
of the way Azure Cloud Shell executes commands using a service principal, instead
of your user account. In this case, the script can’t automatically detect your user
account to assign appropriate permissions to the Azure Key Vault during the
creation of the TDE protector.
3. Clone the GitHub repository that contains the source code for this
book by running the following command:
Azure-SQL-Hyperscale-Revealed/ch10/installsqlhyperscalerevealed
hyperscalenevironment.sh --resource-name-suffix '<your resource
name suffix>' --aad-user-principal-name '<your Azure AD
account UPN>'
246
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
PrimaryRegion='East US'
FailoverRegion='West US 3'
ResourceNameSuffix='<your resource name suffix>'
AadUserPrincipalName='<your Azure AD account UPN>'
Environment='SQL Hyperscale Revealed demo'
baseResourcePrefix='sqlhr'
primaryRegionPrefix=$baseResourcePrefix'01'
failoverRegionPrefix=$baseResourcePrefix'02'
primaryRegionResourceGroupName=$primaryRegionPrefix-$ResourceNameSuffix-rg
failoverRegionResourceGroupName=$failoverRegionPrefix-
$ResourceNameSuffix-rg
subscriptionId="$(az account list --query "[?isDefault].id" -o tsv)"
userId="$(az ad user show --id $AadUserPrincipalName --query 'id' -o tsv)"
privateZone='privatelink.database.windows.net'
sqlAdministratorsGroupSid="$(az ad group show --group 'SQL Administrators'
--query 'id' -o tsv)"
Figure 10-3 shows the creation of the helper variables in the Azure Cloud Shell.
Note These variables will need to be re-created if your Azure Cloud Shell closes
between running commands.
247
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
az identity create \
--name "$baseResourcePrefix-$ResourceNameSuffix-umi" \
--resource-group "$primaryRegionResourceGroupName" \
--location "$primaryRegion" \
--tags Environment="$Environment"
userAssignedManagedIdentityId="/subscriptions/$subscriptionId"\
"/resourcegroups/$primaryRegionResourceGroupName"\
"/providers/Microsoft.ManagedIdentity"\
"/userAssignedIdentities/$baseResourcePrefix-$ResourceNameSuffix-umi"
Figure 10-4 shows the expected output from the user-assigned managed identity
being created.
248
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
scope="/subscriptions/$subscriptionId"\
"/resourcegroups/$primaryRegionResourceGroupName"\
"/providers/Microsoft.KeyVault"\
"/vaults/$baseResourcePrefix-$ResourceNameSuffix-kv"
az role assignment create \
--role 'Key Vault Crypto Officer' \
--assignee-object-id "$userId" \
--assignee-principal-type User \
--scope "$scope"
249
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
Figure 10-5 shows part of the output from assigning the Key Vault Crypto Officer role
to the Key Vault.
Once the role has been assigned, the user account specified in the userId variable
can be used to create the TDE protector key in the Key Vault using the az keyvault key
create command. The identity of the TDE protector key is then assigned to a variable to
use when creating the logical server.
250
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
Figure 10-6 shows partial output from creating the TDE protector.
Figure 10-6. Creating the TDE protector key in the Key Vault
The az role assignment create command is used again to grant the Key Vault
Crypto Service Encryption User role to the service principal that is created as part of the
user-assigned managed identity. The az ad sp list command is used to look up the ID
of the service principal.
--assignee-object-id "$servicePrincipalId" \
--assignee-principal-type ServicePrincipal \
--scope "$scope"
Figure 10-7 shows part of the output from assigning the service principal a role on
the key.
The logical servers will now be able to access the TDE protector key in the Key Vault
once they’ve been assigned the user-assigned managed identity.
--enable-ad-only-auth \
--assign-identity \
--identity-type UserAssigned \
--user-assigned-identity-id "$userAssignedManagedIdentityId" \
--primary-user-assigned-identity-id "$userAssignedManagedIdentityId" \
--key-id "$tdeProtectorKeyId" \
--external-admin-principal-type Group \
--external-admin-name 'SQL Administrators' \
--external-admin-sid "$sqlAdministratorsGroupSid"
Figure 10-8 shows part of the output from creating the logical server.
253
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
sqlServerResourceId="/subscriptions/$subscriptionId"\
"/resourcegroups/$primaryRegionResourceGroupName"\
"/providers/Microsoft.Sql"\
"/servers/$primaryRegionPrefix-$ResourceNameSuffix"
az network private-endpoint create \
--name "$primaryRegionPrefix-$ResourceNameSuffix-pe" \
--resource-group "$primaryRegionResourceGroupName" \
--location "$primaryRegion" \
--vnet-name "$primaryRegionPrefix-$ResourceNameSuffix-vnet" \
--subnet "data_subnet" \
--private-connection-resource-id "$sqlServerResourceId" \
--group-id sqlServer \
--connection-name "$primaryRegionPrefix-$ResourceNameSuffix-pl"
Once the private endpoint has been created, we can create a private DNS zone
that will be used to resolve the name of the logical server within the virtual network.
The private DNS zone is created using the az network private-dns zone create
command. The --name is set to the domain name suffix used by databases that
is connected to private endpoints. For Azure Cloud, this is privatelink.database.
windows.net.
Next, the private DNS zone is connected to the virtual network using the az network
private-dns link vnet create command, specifying the virtual network name in
the --virtual-network parameter and the private DNS zone name in the --zone-name
parameter.
254
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
Finally, a DNS zone group for the logical server private endpoint is created in the
private DNS zone. This will ensure that the DNS A-record for the logical server is created
and kept up-to-date in the private DNS zone. This is done by the az network private-
endpoint dns-zone-group create command.
The logical server is now connected to the virtual network with a private endpoint
and is not accessible on a public IP address.
• --server: This is the name of the logical server that the database is
being created in.
255
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
az sql db create \
--name 'hyperscaledb' \
--server "$primaryRegionPrefix-$ResourceNameSuffix" \
--resource-group "$primaryRegionResourceGroupName" \
--edition 'Hyperscale' \
--capacity 2 \
--family 'Gen5' \
--compute-model 'Provisioned' \
--ha-replicas 2 \
--zone-redundant \
--backup-storage-redundancy 'GeoZone' \
--tags $tags
Figure 10-9 shows part of the output from creating the Hyperscale database using the
az sql db create command. The full output is truncated for brevity.
256
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
257
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
logAnalyticsWorkspaceResourceId="/subscriptions/$subscriptionId"\
"/resourcegroups/$primaryRegionResourceGroupName"\
"/providers/microsoft.operationalinsights"\
"/workspaces/$primaryRegionPrefix-$ResourceNameSuffix-law"
az sql server audit-policy update \
--name "$primaryRegionPrefix-$ResourceNameSuffix" \
--resource-group "$primaryRegionResourceGroupName" \
--log-analytics-workspace-resource-id
"$logAnalyticsWorkspaceResourceId" \
--log-analytics-target-state Enabled \
--state Enabled
Figure 10-10 shows some partial output from the az sql server audit-policy
update command.
The diagnostic logs also need to be sent to the Log Analytics workspace from the
database by using the az monitor diagnostic-settings create command. The
--workspace parameter will be set to the resource ID of the Log Analytics workspace.
The --logs parameter should be set to a JSON array of diagnostic log categories to send
to the workspace. Here’s an example:
logs='[
{
"category": "SQLInsights",
258
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
},
{
"category": "AutomaticTuning",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]'
logAnalyticsWorkspaceResourceId="/subscriptions/$subscriptionId"\
"/resourcegroups/$primaryRegionResourceGroupName"\
"/providers/microsoft.operationalinsights"\
"/workspaces/$primaryRegionPrefix-$ResourceNameSuffix-law"
databaseResourceId="/subscriptions/$subscriptionId"\
"/resourcegroups/$primaryRegionResourceGroupName"\
"/providers/Microsoft.Sql"\
"/servers/$primaryRegionPrefix-$ResourceNameSuffix"\
"/databases/hyperscaledb"
az monitor diagnostic-settings create \
--name "Send all logs to $primaryRegionPrefix-
$ResourceNameSuffix-law" \
--resource "$databaseResourceId" \
--logs "$logs" \
--workspace "$logAnalyticsWorkspaceResourceId"
Tip The list of available diagnostic logging categories for a Hyperscale database
can be obtained by running the az monitor diagnostic-settings list
command and setting --resource to the resource ID of the Hyperscale database.
259
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
Figure 10-11 shows partial output from configuring the diagnostic settings on the
database.
The deployment and configuration of the Hyperscale database in the primary region
is now complete. We can now deploy the failover region.
260
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
region. The failover logical server will use the same user-assigned
managed identity as the primary logical server so that it can
access the TDE protector key in the primary region’s Key Vault.
2. Create the private endpoint in the failover virtual network for the
failover logical server using the az network private-endpoint
create command.
4. Connect the private DNS zone to the virtual network using the az
network private-dns link vnet create command.
5. Create the DNS zone group in the private endpoint using the az
network private-endpoint dns-zone-group create command.
The failover logical server will now be connected to the virtual network, configured
to use customer-managed encryption and to use the SQL Administrators Azure
AD group.
• --server: This is the name of the primary logical server that contains
the database to replicate.
261
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
Figure 10-12 shows partial output from running the command to create the geo
replica.
Figure 10-12. Creating the geo replica using the Azure CLI
263
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
Note You can still find the code for this in the Install-
installsqlhyperscalerevealedhyperscalenevironment.sh file in the
ch10 directory provided in the source code for this book.
Remove the Key Vault Crypto Officer Role from the Key Vault
The final task is to remove the Key Vault Crypto Officer role from the Key Vault for the
account running the script. This is simply a security hygiene task that can be performed
by running the az role assignment delete command.
scope="/subscriptions/$subscriptionId"\
"/resourcegroups/$primaryRegionResourceGroupName"\
"/providers/Microsoft.KeyVault"\
"/vaults/$baseResourcePrefix-$ResourceNameSuffix-kv"
az role assignment delete \
--assignee "$userId" \
--role "Key Vault Crypto Officer" \
--scope "$scope"
This command will not produce any output. The Hyperscale architecture that was
defined in Chapter 4’s Figure 4-1 has now been deployed using the Azure CLI commands
and is ready to use.
Summary
In this chapter, we introduced imperative infrastructure as code to deploy a Hyperscale
environment using the Azure CLI with a shell script. We looked at the Azure CLI
commands to create the logical server as well as connect it to a virtual network. We also
showed the Azure CLI commands that are used to configure transparent data encryption
using a customer-managed key stored in a Key Vault. The command for creating the
Hyperscale database and the geo replica were also demonstrated. Finally, we showed
how to configure audit and diagnostic logging to an Azure Log Analytics workspace.
264
Chapter 10 Deploying Azure SQL DB Hyperscale Using Bash and Azure CLI
265
CHAPTER 11
Note This chapter is not intended to be a primer on Azure Bicep, its syntax, or
other declarative methods. Microsoft provides many great free resources to help
learn Azure Bicep here: http://aka.ms/learnbicep and https://aka.
ms/bicep.
If you’re not familiar with Azure Bicep, it is strongly recommended to at least learn
the basics before reading through it. If you don’t have the time to learn the Azure Bicep
language, then you should feel free to skip this chapter and refer to it at a later date once
you’ve become familiar with the language.
267
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_11
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
As with the previous chapters, the complete set of Azure Bicep files and scripts
required to deploy the environment can be found in the ch11 directory in the files
provided for this book. You should review these files to familiarize yourself with the
process of deploying a SQL Hyperscale environment with all the “bells and whistles.”
Note The Azure Bicep files are transparently transpiled into an older declarative
syntax called an ARM template by the commands that are used to send them
to the ARM engine. The transpilation process can be performed manually for
diagnostic purposes or if your tools support only the older ARM template syntax.
268
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
Unlike the previous chapters, however, we don’t need to start by deploying a starting
environment. Instead, the entire environment, including the starting resources (virtual
networks, Key Vault, and Log Analytics workspaces), are deployed using the Azure Bicep files.
Both PowerShell and Bash versions of the script are provided for your convenience.
For the PowerShell version, the Azure PowerShell New-AzDeployment is used to send
the files to the ARM engine. For the Bash version, the Azure CLI az deployment sub
create command is used. Both versions use the same parameters and the same Azure
Bicep files.
Both scripts are provided for you in the ch11 directory
of the files provided for this book. The Bash script is called
installsqlhyperscalerevealedhyperscalenevironment.sh, and the PowerShell script
is called Install-SQLHyperscaleRevealedHyperscaleEnvironment.ps1.
269
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
3. Clone the GitHub repository that contains the source code for this
book by running the following command:
./Azure-SQL-Hyperscale-Revealed/ch10/Install-SQLHyperscaleRevealed
HyperscaleEnvironment.ps1 -ResourceNameSuffix
'<your resource name suffix>'
Because of the number of resources being created, the deployment process may take
30 minutes or more.
270
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
3. Clone the GitHub repository that contains the source code for this
book by running the following command:
./Azure-SQL-Hyperscale-Revealed/ch11/installsqlhyperscalerevealedhy
perscalenevironment.sh --resource-name-suffix '<your resource
name suffix>'
Because of the number of resources being created, the deployment process may take
30 minutes or more.
271
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
Note Some of the resource type versions that are used in this book are in
preview. These are subject to change but are often required to be used to support
the latest features of the underlying resources.
This resource type just needs the name and location properties to be set.
You can find the complete Azure Bicep module to create the user-assigned managed
identity in the user_assigned_managed_identity.bicep file found in the ch11/modules
directory in the files provided for this book.
272
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
]
}
}
The name needs to be set to the name of the Key Vault concatenated with the name
of the key. The kty, keySize, and keyOps properties must be set according to the
requirements for Azure SQL customer-managed keys for transparent data encryption.
If wrapKey or unwrapKey is not included in the keyOps, then errors will occur when
enabling encryption.
The user-assigned managed identity will need to be granted the Key Vault Crypto
Service Encryption role on the TDE protector key so that it can access it. This is done
by obtaining the role ID for the Key Vault crypto service encryption user using its GUID
with the Microsoft.Authorization/roleDefinitions resource type. The role ID and
the user-assigned managed identity are provided to the Microsoft.Authorization/
roleAssignments resource type to assign the role.
273
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
This is all that is required to create the TDE protector key. If we compared this to the
process for using Azure PowerShell or the Azure CLI, it is much simpler and requires
fewer steps.
You can find the complete Azure Bicep module to create the Azure Key Vault and the
TDE protector key in the key_vault_with_tde_protector.bicep file found in the ch11/
modules directory in the files provided for this book.
274
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
275
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
This will require the privateLinkServiceId to be set to the resource ID of the logical
server. The subnet.id will need to be set to the resource ID of the subnet to connect the
logical server to.
Next, the private DNS zone needs to be created and then linked to the virtual
network to enable name resolution of the logical server in the virtual network. This
is done using the Microsoft.Network/privateDnsZones and Microsoft.Network/
privateDnsZones/virtualNetworkLinks resource types.
The name of the private DNS zone needs to be assembled by looking up the Azure
SQL server hostname for the Azure environment being used, prefixed with privatelink.
The final step of configuring the networking is to link the private endpoint
for the SQL logical server to the private DNS zone using the Microsoft.Network/
privateEndpoints/privateDnsZoneGroups resource type.
276
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
277
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
The usual part about this configuration is that we need to create the master database,
before we can create the Microsoft.Insights/diagnosticSettings extension resource.
278
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
279
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
You will note the parent is set to the logical server that was created earlier. The sku
must be configured as follows:
280
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
enabled: true
retentionPolicy: {
days: 0
enabled: false
}
}
]
workspaceId: logAnalyticsWorkspaceId
}
}
Because this is an extension resource type, the scope needs to be set to the SQL
Hyperscale database resource.
The logs array can be configured with the categories of diagnostic logs to send to the
Log Analytics workspace, while workspaceId should be set to the resource ID of the Log
Analytics workspace.
You can find the complete Azure Bicep module to create the Hyperscale database
and configure diagnostic logging in the sql_hyperscale_database.bicep file found in
the ch11/modules directory in the files provided for this book.
281
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
name: '${failoverRegionPrefix}-${resourceNameSuffix}'
location: failoverRegion
environment: environment
tenantId: subscription().tenantId
userAssignedManagedIdentityResourceId: userAssignedManagedIdentity.
outputs.userAssignedManagedIdentityResourceId
tdeProtectorKeyId: keyVault.outputs.tdeProtectorKeyId
sqlAdministratorsGroupId: sqlAdministratorsGroupId
vnetId: failoverVirtualNetwork.outputs.vnetId
dataSubnetId: failoverVirtualNetwork.outputs.dataSubnetId
logAnalyticsWorkspaceName: failoverLogAnalyticsWorkspace.outputs.
logAnalyticsWorkspaceName
logAnalyticsWorkspaceId: failoverLogAnalyticsWorkspace.outputs.
logAnalyticsWorkspaceId
}
}
However, to deploy the replica database, we will again use the Microsoft.Sql/
servers/databases resource type, but this time, we’ll need to adjust the properties
slightly.
282
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
sourceDatabaseId: sourceDatabaseId
zoneRedundant: false
}
}
When we’re creating a replica, we need to set createMode to Secondary and set
sourceDatabaseId to the resource ID of the primary Hyperscale database. We also need
to set secondaryType to Geo to create a geo replica. Again, the code here is much simpler
to understand than with Azure PowerShell and the Azure CLI.
You can find an example of reusing modules in a single deployment in the sql_
hyperscale_revealed_environment.bicep file found in the ch11 directory in the files
provided for this book.
New-AzDeployment `
-Name "sql-hyperscale-revealed-env-$resourceNameSuffix-$(Get-Date
-Format 'yyyyMMddHHmm')" `
-Location 'West US 3' `
-TemplateFile ./Azure-SQL-Hyperscale-Revealed/ch11/sql_hyperscale_
revealed_environment.bicep `
-TemplateParameterObject @{
'resourceNameSuffix' = $resourceNameSuffix
'sqlAdministratorsGroupId' = $sqlAdministratorsGroupId
}
283
Chapter 11 Deploying Azure SQL DB Hyperscale Using Azure Bicep
determine the ID of the Azure AD group used for SQL Administrators. This is required
to deploy the logical server because currently there is no way of doing this directly in
Azure Bicep.
Figure 11-1 shows the sample output produced once the resources have been
successfully deployed.
Because Azure Bicep is idempotent, running the command again will quickly return
the same output and will not change any of the resources, unless you’ve changed the
Azure Bicep files or the deployed resources have been changed by a different method.
Summary
In this chapter, we demonstrated the deployment of a complete Hyperscale environment
using declarative infrastructure as code with Azure Bicep. The environment was able to
be deployed more quickly using the Azure Bicep than with a typical imperative method
because many of the resources are able to be deployed in parallel. Parallel deployments
with imperative methods are possible but require significantly more code to achieve.
We also showed that Azure Bicep syntax can be much more compact and readable
than the equivalent Azure PowerShell or Azure CLI. Many other benefits are also more
easily achievable with Azure Bicep, such as best-practice evaluation, easier-to-detect
issues, and linting (removing unnecessary code).
There is almost no downside, except for initially learning the new syntax, to using
Azure Bicep or another declarative method.
In the next chapter, we will look at the performance of SQL Hyperscale in depth,
especially when compared with other Azure SQL offerings.
284
CHAPTER 12
Testing Hyperscale
Database Performance
Against Other Azure SQL
Deployment Options
In the previous chapter, we talked about how to deploy the SQL Hyperscale environment
using Azure Bicep. We explained a few of the key Azure Bicep resources required to
deploy the SQL Hyperscale environment and supporting resources.
In this chapter, we are going to do an overall performance comparison between the
traditional Azure architecture and Hyperscale architecture. For this purpose, we are
going to deploy three different Azure SQL database service tiers.
All Azure SQL resources will be deployed in the same Azure region and on the same
logical Azure SQL Server instance. We will also deploy all of these on Standard-series
(Gen5) hardware configuration with eight vCores. Figure 12-1 shows the Azure SQL
Database service tiers and hardware we will use for testing.
285
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_12
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
There are multiple ways to run benchmark tests against your Azure SQL
deployments. One of the available tools for this purpose is HammerDB. It is open source
and offers Transaction Processing Performance Council (TPC) standard metrics for
SQL in the cloud or in on-premises servers. The Transaction Processing Performance
Council establishes standards that are intended to promote the fast, reliable execution
of database transactions. TPC benchmarking measures the performance, speed, and
reliability of transactions.
Note Founded in 1985, the TPC consists of major hardware and software
vendors such as Microsoft, Hewlett-Packard (HP), IBM, and Dell. The TPC
specifications are published benchmarks widely accepted by all leading database
vendors.
HammerDB
For testing purposes, we are going to use the HammerDB tool. HammerDB is free and
open source software and one of the leading benchmarking and load testing tools for the
most popular databases such as SQL Server.
Note HammerDB was our preferred tool for these tests and performing a
comparison between different Azure SQL Database deployments, including
the Hyperscale service tier. However, HammerDB is not an officially endorsed
measuring standard, and results may vary.
286
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
HammerDB TPROC-C Workload
For these tests, we will use the TPROC-C OLTP workload implemented in HammerDB
and derived from TPC-C. The TPROC-C HammerDB workload name means
“Transaction Processing Benchmark derived from the TPC-C standard specification.”
The reason for choosing this open source workload is to run the HammerDB tool so
that we can run these tests in the easiest and most efficient way against our supported
environment. The HammerDB TPROC-C workload is designed to be reliable and tuned
to produce consistently repeatable and accurate results. Therefore, if we rerun the same
test with the same hardware configuration with the same parameters, we will get almost
identical results, with only marginal variations.
The main goal of executing these tests is to gain some certainty as to whether the
new database deployment will be able to handle the anticipated workload.
HammerDB Step-by-Step
For these tests we will use HammerDB v4.5 on Windows using the graphical user
interface. HammerDB is also available for Linux. Both the Windows and Linux versions
(since v3.0) have a command-line version as well. Figure 12-2 shows the current
HammerDB version at the time of writing.
287
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
For more information on HammerDB, see the official HammerDB web page at
https://www.HammerDB.com.
Schema Build
The first step of using HammerDB to benchmark your database is to build the schema
of the test database. The following steps show how to execute a schema build using the
HammerDB tool:
288
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
3. Expand the Schema Build branch and then select Options. See
Figure 12-5.
289
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
4. Configure the settings in the Microsoft SQL Server TPROC-C Build
Options box to enable the HammerDB benchmark tool to connect
to the Azure SQL Database instance. For this test we created 50
warehouses and 32 virtual users, as shown in Figure 12-6.
• SQL Server: Set this to the DNS name of the logical SQL server
containing the Azure SQL Database instance we are evaluating. This
can be found in the Azure Portal on the Overview blade of the logical
SQL server resource.
290
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
• SQL Server Port: Since we enabled TCP, the default SQL Server port
1433 will be used to connect to the logical server.
• SQL Server ODBC Driver: Choose the available Microsoft SQL ODBC
driver you will use to connect to the Azure SQL Server database.
• SQL Server User ID: Specify a SQL user account with access to the
logical SQL Server instance and the database being tested.
• SQL Server User Password: Specify the SQL user account password.
5. After setting all the parameters and supplying the credentials that
HammerDB will use to connect to your database, HammerDB
will be ready to build the schema and populate the data for the
database that will be used for benchmarking.
Tip To be able to run the schema build process, the database needs to be
created first.
6. HammerDB can now build the schema and populate the tables by
selecting TPROC-C, then Schema Build, and then Build from the
Benchmark box or selecting Build from the toolbar. See Figure 12-7.
291
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Depending on the parameters that were entered and the environment that is being
tested, this process could take from a few minutes to a few hours. See Figure 12-9.
292
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
293
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
There are two driver scripts you can choose from.
• Test Driver Script: This mode is suitable for a small number of virtual
users. It displays the virtual user output in real time by writing to the
display. This may have an impact on throughput performance.
For this test we will use the timed driver script and 1,000 transactions per user to
be run against all warehouses available. These values can be changed to suit your test
requirements. Figure 12-11 shows an example of setting the HammerDB SQL Server
TPROC-C Driver Script Options parameters.
294
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Figure 12-11. HammerDB SQL Server TPROC-C Driver Script Options box
For these tests, we will configure the Microsoft SQL Server TPROC-C Driver Options
parameters like this:
295
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Driver Script option, it should be set to a high enough value so that
the virtual users do not complete their transactions before the timed
test is complete.
• Minutes of Ramp-up Time: The monitoring for each virtual user will
wait for them to connect to the database and build up the database
buffer cache before the test results start being counted. This should
be set to a value long enough for a workload to reach a steady
transaction rate.
• Minutes for Test Duration: This is the test duration set in the driver
script, which is measured as the time the monitor thread waits
between the first timed value and the second one when the test is
complete.
• Use All Warehouses: If set to true, the virtual users will select a
different warehouse for each transaction from the shared list of
warehouses to ensure greater I/O activity. If set to false, each virtual
user selects a home warehouse at random for the entire test by
default.
296
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
• Time Profile: If this is set to true, it sets client-side time profiling that
is configured in the generic.xml file. There are two options that
can be set.
• Xtprof: This profiles all virtual users and prints their timing
outputs at the end of a run.
• Etprof: This profiler times only the first virtual user and prints the
output every 10 seconds.
• Asynch Client Login Delay: The delay that each virtual user will have
before each asynchronous client is logged in.
297
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
After configuring the driver script, we can specify the number of virtual users and
iterations that will be used to simulate load. In HammerDB, select TPROC-C, then
Virtual User, and then Options in the Benchmark box. For this example, we used the
parameters shown in Figure 12-12.
Note While running a timed workload script using HammerDB, one additional
virtual user will be automatically created to monitor the workload.
The following are the virtual option parameters that you can configure:
• Virtual Users: Specify the number of virtual users that will be created
and used for testing.
• Repeat Delay (ms): This is the amount of time a virtual user will wait
between each run of the driver script.
298
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
• Iterations: This is the number of times that the driver script will be
run by each virtual user.
• Show Output: Set this to true to show the output report for each
virtual user.
Note If the Show Output option is enabled, it will put additional load on your
system and so might affect your benchmark results.
• Log Output to Temp: This setting causes the logs from each virtual
user to be written to a text file in the temp folder.
• Use Unique Log Name: This ensures a unique filename is created for
the log file.
• Log Timestamps: This sets a timestamp for each log entry in the
log file.
Autopilot Options
HammerDB provides an automated stress test function that can be configured using the
autopilot options. This feature executes the tests with a specific number of virtual users
in an automated fashion. To use the Autopilot feature in HammerDB, follow these steps:
3. Set the Minutes per Test in Virtual User Sequence field to five
minutes or higher, as shown in Figure 12-13.
299
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Tip It is recommended that Active Virtual User Sequence is configured to suit the
workload that is being evaluated.
300
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
All our Azure SQL Database deployments will use the same logical SQL Server
instance, and the HammerDB tool will be run from a virtual machine in the same Azure
region as the logical server. The virtual machine is connecting to the logical server via the
public endpoint.
301
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Azure SQL Database General Purpose Service Tier (GP_Gen5_8)
First, we are going to run a schema build operation against the Azure SQL Database
instance with the General Purpose service tier with eight vCores. This is the lowest
specification database deployment we are going to use in these tests. Therefore, we
expect the performance results to reflect that; see Table 12-1.
Hardware Gen5
vCores 8
Memory (GB) 41.5
Max data size (GB) 2048
Max log size (GB) 614
Storage type Remote SSD
Read I/O latency (approximate ms) 5 to 10
Write I/O latency (approximate ms) 5 to 7
Max log rate (MBps) 36
302
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
2. Run the schema build against the Azure SQL Database instance
with the General Purpose service tier deployment. Figure 12-17
shows the schema build progress against the General Purpose
service tier with a transaction counter enabled.
303
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Within the HammerDB transaction counter log, we can find all the transaction
timestamps.
We can examine resource usage through the Azure Portal in the logical SQL Server
instance on the Metrics blade by using the following metrics:
• CPU percentage (max)
• Data IO percentage (max)
• Log IO percentage (max)
• Workers percentage (max)
304
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Figure 12-18 shows the metrics for the logical server while running this test.
Figure 12-18. Azure Portal metrics graph for the General Purpose service tier
Tip For more information on monitoring an Azure SQL Database instance and a
logical SQL server, please see Chapter 13.
305
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-2. Azure SQL Database with Business-Critical Service
Tier (BC_Gen5_8) Deployment Specifications
Compute Size (Service Objective) BC_Gen5_8
Hardware Gen5
vCores 8
Memory (GB) 41.5
Max data size (GB) 2048
Max log size (GB) 614
Max local storage size (GB) 4096
Storage type Local SSD
Read I/O latency (approximate ms) 1 to 2
Write I/O latency (approximate ms) 1 to 2
Max log rate (MBps) 96
Note The Business Critical service tier has database data and log files on an
SSD drive attached to the node and an approximate storage I/O latency of 1 to 2
milliseconds.
Figure 12-19 shows the schema build progress against the Business Critical service
tier with the transaction counter enabled.
306
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
We can examine resource usage through the Azure Portal in the logical SQL server
on the Metrics blade by using CPU percentage (max), Data IO percentage (max), Log IO
percentage (max), and Workers percentage (max). See Figure 12-20.
307
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Figure 12-20. Azure Portal metrics graph for the Business Critical service tier
308
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-3. Azure SQL Database with Hyperscale Service Tier
(HS_Gen5_8) Deployment Specifications
Compute Size (Service Objective) HS_Gen5_8
Hardware Gen5
vCores 8
Memory (GB) 41.5
RBPEX Size 3x Memory
Max data size (TB) 100
Max log size (TB) Unlimited
Max local SSD IOPS 32000
Max log rate (MBps) 105
Local read I/O latency (approximate ms) 1 to 2
Remote read I/O latency (approximate ms) 1 to 5
Write IO latency (approximate ms) 3 to 5
Storage type Multitiered
Tip For Hyperscale, performance depends heavily on your workload type. Bear
in mind that latency numbers are approximate and not guaranteed; those numbers
are based on a typical steady workload.
Figure 12-21 shows the schema build progress against the Hyperscale service tier
with the transaction counter enabled.
309
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Within the HammerDB transaction counter log, we can find all the transaction
timestamps.
We can examine resource usage through the Azure Portal in the logical SQL server
on the Metrics blade by using CPU percentage (max), Data IO percentage (max), Log IO
percentage (max), and Workers percentage (max). See Figure 12-22.
310
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Figure 12-22. Azure Portal metrics graph for the Hyperscale service tier
311
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
TPROC-C Workload Metrics
In the next stage of this evaluation process, we will run the TPORC-C workload against
all three Azure SQL Database service tiers. We will specify the following parameters for
TPROC-C Driver options:
1. Set Total Transactions per User to 1000 since we are using the
Timed Driver Script option. This should a high enough value so
that our virtual users do not complete their transactions before
the timed test is complete.
312
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Next, we will specify the following parameters for the TPROC-C Virtual User
options.
5. Set the number of virtual users to 32. This is the number of virtual
users that will be created to execute the tests.
6. Set the iterations to 100. This is the number of times that the driver
script is going to be run by each virtual user. See Figure 12-24.
313
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
The virtual users will be created, and the driver script iterations will begin.
314
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Azure SQL Database General Purpose Service Tier (GP_Gen5_8)
You can run the following T-SQL statement to see the resource limitations of your
selected Azure SQL deployment:
/* SLO, Server Name, CPU Limit, MAX Log Throughput, MAX DB Size*/
SELECT
slo_name as 'Service Level Objective'
, server_name as 'Server Name'
, cpu_limit as 'CPU Limit'
, database_name as 'DB Name'
, primary_max_log_rate/1024/1024 as 'Log Throughput MB/s'
, max_db_max_size_in_mb/1024/1024 as 'MAX DB Size in TB'
FROM sys.dm_user_db_resource_governance
GO
Table 12-5 shows the T-SQL query result from the sys.dm_user_db_resource_
governance DMV, showing actual configuration and capacity settings for Azure SQL
Database deployment.
To see the maximum amount of committed memory for the selected Azure SQL
Database deployment, run the following T-SQL statement:
Table 12-6 shows the query result from sys.dm_os_job_object showing the
maximum amount of committed memory for the Azure SQL Database deployment.
315
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-6. Maximum Amount
of Committed Memory
Max Memory in GB
41.52
Within the HammerDB transaction counter log, we can find all the transaction
timestamps.
The tests were completed using 32 virtual users achieving 59,112 new orders per
minute (NOPM) from 139,351 transactions per minute (TPM). Figure 12-26 shows
the Azure Portal metrics during TPROC-C workload execution against the Azure SQL
Database General Purpose service tier (GP_Gen5_8).
316
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Figure 12-26. Azure Portal metrics graph for the General Purpose service tier
Table 12-7 lists more details about accumulated waits during the TPROC-C workload
execution for the General Purpose service tier deployment.
317
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-7. Query Store Wait Categories Statistics Accumulated During SQL
Server TPROC-C Workload Execution (GP_Gen5_8)
Wait wait category avg wait min wait max wait ▼ total wait execution
category id time time time time count
318
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
To see the maximum amount of committed memory for selected Azure SQL
Database deployment, run the following T-SQL statement:
Table 12-9 shows the query result from sys.dm_os_job_object that shows the
maximum amount of committed memory for Azure SQL Database deployment.
Within the HammerDB transaction counter log, we can find all the transaction
timestamps.
• The transactions started at 02:56:40.
The tests were completed using 32 virtual users achieving 130,662 new orders per
minute (NOPM) from 308,240 transactions per minute (TPM). Figure 12-27 shows the
Azure Portal metrics during the TPROC-C workload execution against the Azure SQL
Database Business Critical General service tier (BC_Gen5_8).
319
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Figure 12-27. Azure Portal metrics graph for the Business Critical service tier
You can find more details on the accumulated waits during the TPROC-C workload
execution for the Business Critical service tier deployment in Table 12-10.
320
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-10. Query Store Wait Categories Statistics Accumulated During SQL
Server TPROC-C Workload Execution (BC_Gen5_8)
wait wait category avg wait min wait max wait ▼ total wait execution
category id time time time time count
• With data pages cached in the buffer pool (in memory) and
RBPEX cache
321
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-11. Actual Configuration and Capacity Settings Query Result
Service-Level Objective Server Name CPU Limit DB Name Log Throughput Max DB
MB/s Size in TB
To see the maximum amount of committed memory for the selected Azure SQL
Database deployment, run the following T-SQL statement:
Table 12-12 shows the query result from sys.dm_os_job_object, showing the
maximum amount of committed memory for the Azure SQL Database deployment.
For the Azure SQL Hyperscale Database deployment with eight vCores, the memory
size is 41.5GB, which results in 125GB resilient buffer pool size. To see the size of
compute replica RBPEX cache, we can run the following T-SQL statement:
Table 12-13 shows the query result from DMV function sys.dm_io_virtual_file_
stats and returns the number of bytes used on the disk for this file, which presents the
compute node RBPEX size for the Azure SQL Database deployment.
322
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-13. Hyperscale Service
Tier Compute Node RBPEX Size
Resilient Buffer Pool File Size in GB
125
Tip The Azure SQL Hyperscale deployment compute node RPB size is equal to
three times the maximum memory.
In this scenario, we will run the TPROC-C workload immediately after the schema
build is complete. Bear in mind that after the schema build is done, there are pages
already cached in RBPEX. You can use the following SQL statement to fetch the RBPEX
usage statistics and cache size:
SELECT
DB_NAME (database_id) AS 'DB Name'
, file_id AS 'File ID'
, num_of_reads AS 'Total Reads',
CASE WHEN num_of_reads = 0 THEN 0 ELSE (num_of_bytes_read / num_of_reads)
END AS 'Avg Bytes Per Read',
CASE WHEN num_of_reads = 0 THEN 0 ELSE (io_stall_read_ms / num_of_reads)
END AS 'Read Latency',
num_of_writes AS 'Total Writes',
CASE WHEN num_of_writes = 0 THEN 0 ELSE (num_of_bytes_written / num_of_
writes) END AS 'Avg Bytes Per Write',
CASE WHEN num_of_writes = 0 THEN 0 ELSE (io_stall_write_ms / num_of_writes)
END AS 'Write Latency',
CASE WHEN (num_of_reads = 0 AND num_of_writes = 0) THEN 0 ELSE (io_stall /
(num_of_reads + num_of_writes)) END AS 'Overall Latency',
CASE WHEN (num_of_reads = 0 AND num_of_writes = 0) THEN 0 ELSE ((num_of_
bytes_read + num_of_bytes_written) / (num_of_reads + num_of_writes)) END AS
'Avg Bytes Per IO'
,size_on_disk_bytes / 1024 / 1024 / 1024 AS 'RBPX Cache Size in GB'
FROM sys.dm_io_virtual_file_stats(0,NULL)
323
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-14 shows RBPEX usage statistics example before the schema build was
executed against the Azure SQL Hyperscale database.
From these results, we can see that the RBPEX cache is almost empty. After the
schema build is complete, the cache is going to look a bit different. Table 12-15 shows
that the number of writes in the RBPEX cache is high.
Next, we will run the TPROC-C workload against our Azure SQL Hyperscale
database. For the TPROC-C workload execution, we will use the same parameters that
we used in the previous section. This will take approximately 10 minutes including the
Timed Driver Script duration of 8 minutes and 2 minutes of ramp-up time.
After the TPROC-C Workload execution is finished, the RBPEX cache of our Azure SQL
Hyperscale database is going to look significantly different, as demonstrated in Table 12-16.
324
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
As we can see, the number of the writes are increasing in RBPEX cache, which
is expected due to the HammerDB TPROC-C workload mostly consisting of update
SQL statements. The performance of our Azure SQL Database Hyperscale service tier
deployment is going to heavily depend on the workload type.
Within the HammerDB transaction counter log, we can find all transaction timestamps.
• The transactions started at 03:48:10.
The test completed for 32 virtual users, achieving 120,896 new orders per minute
(NOPM) from 285,210 transactions per minute (TPM). Figure 12-28 shows the metrics
for the logical SQL server from the Azure Portal during the TPROC-C workload execution
against the Azure SQL Database Hyperscale service tier (HS_Gen5_8).
325
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Figure 12-28. Azure Portal metrics graph for Hyperscale service tier
Table 12-17 shows the results for the query store wait category statistics accumulated
during the SQL Server TPROC-C workload execution (HS_Gen5_8).
326
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-17. Query Store Wait Category Statistics (HS_Gen5_8)
Wait wait category avg wait min wait max wait ▼ total wait execution
category id time time time time count
To better understand which wait types belong to each wait category in the query
store, please see Table 12-18.
0 Unknown Unknown
1 CPU SOS_SCHEDULER_YIELD
2 Worker THREADPOOL
Thread
3 Lock LCK_M_%
4 Latch LATCH_%
5 Buffer Latch PAGELATCH_%
6 Buffer IO PAGEIOLATCH_%
7 Compilation RESOURCE_SEMAPHORE_QUERY_COMPILE
8 SQL CLR CLR%, SQLCLR%
(continued)
327
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-18. (continued)
9 Mirroring DBMIRROR%
10 Transaction XACT%, DTC%, TRAN_MARKLATCH_%, MSQL_XACT_%, TRANSACTION_
MUTEX
11 Idle SLEEP_%, LAZYWRITER_SLEEP, SQLTRACE_BUFFER_FLUSH,
SQLTRACE_INCREMENTAL_FLUSH_SLEEP, SQLTRACE_WAIT_ENTRIES,
FT_IFTS_SCHEDULER_IDLE_WAIT, XE_DISPATCHER_WAIT, REQUEST_
FOR_DEADLOCK_SEARCH, LOGMGR_QUEUE, ONDEMAND_TASK_QUEUE,
CHECKPOINT_QUEUE, XE_TIMER_EVENT
12 Preemptive PREEMPTIVE_%
13 Service BROKER_% (but not BROKER_RECEIVE_WAITFOR)
Broker
14 Tran Log IO LOGMGR, LOGBUFFER, LOGMGR_RESERVE_APPEND, LOGMGR_FLUSH,
LOGMGR_PMM_LOG, CHKPT, WRITELOG
15 Network IO ASYNC_NETWORK_IO, NET_WAITFOR_PACKET, PROXY_NETWORK_IO,
EXTERNAL_SCRIPT_NETWORK_IOF
16 Parallelism CXPACKET, EXCHANGE, HT%, BMP%, BP%
17 Memory RESOURCE_SEMAPHORE, CMEMTHREAD, CMEMPARTITIONED,
EE_PMOLOCK, MEMORY_ALLOCATION_EXT, RESERVED_MEMORY_
ALLOCATION_EXT, MEMORY_GRANT_UPDATE
18 User Wait WAITFOR, WAIT_FOR_RESULTS, BROKER_RECEIVE_WAITFOR
19 Tracing TRACEWRITE, SQLTRACE_LOCK, SQLTRACE_FILE_BUFFER, SQLTRACE_
FILE_WRITE_IO_COMPLETION, SQLTRACE_FILE_READ_IO_COMPLETION,
SQLTRACE_PENDING_BUFFER_WRITERS, SQLTRACE_SHUTDOWN, QUERY_
TRACEOUT, TRACE_EVTNOTIFF
(continued)
328
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-18. (continued)
In our test example, there are waits related to the parallelism (CXCONSUMER, CXPACKET)
and buffer I/O waits (PAGEIOLATCH_EX, PAGEIOLATCH_SH). If we examine this in further
detail, we can see that the Tran Log IO wait category with the WRITELOG wait type is the
dominant wait, as shown in Figure 12-29. We already mentioned that the HammerDB
TPROC-C workload is mostly consisting of update SQL statements, WRITELOG wait type
will be expected as a predominant wait type in both of our testing scenarios.
329
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
330
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
In this scenario, we will empty the RBPEX cache of the compute node after the
schema build execution is finished. See Table 12-19.
From the query result shown in Table 12-19, you can see that the total writes are
almost gone on the compute node’s RBPEX cache. The next step would be to execute the
TPROC-C workload again.
Within the HammerDB transaction counter log, we can find all the transaction
timestamps.
The test completed for 32 virtual users, achieving 100,884 new orders per minute
(NOPM) from 238,153 transactions per minute (TPM). Figure 12-30 shows the test results
for the Azure SQL Database Hyperscale service tier (HS_Gen5_8).
331
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Figure 12-30. Azure Portal metrics graph for Hyperscale service tier
Table 12-20 shows the query wait statistics accumulated during the SQL Server
TPROC-C workload execution.
332
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-20. Query Store Wait Categories (HS_Gen5_8)
wait wait avg wait min wait max wait ▼ total wait execution
category id category time time time time count
We can see that there are waits related to the Tran Log IO wait category (WRITELOG
wait type). In addition, in the dominant wait category, we can see Buffer IO waits
(PAGEIOLATCH_EX and PAGEIOLATCH_SH). See Figure 12-31.
333
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
• The PAGEIOLATCH wait type occurs when the page is not available in
the buffer pool or RBPEX cache of the compute node and a GetPage@
LSN request is sent to the page server. If the page server has the
page, the page will be returned to the compute node. However, if the
page does not exist on the page server RBPEX, then the GetLogBlock
request will be sent to the Log service. Every page request will create
a PAGEIOLATCH wait type.
We can conclude from these two scenarios that Hyperscale heavily relies on
workload type and capability to utilize the compute node buffer pool and RBPEX
caching mechanism. If pages are read from the compute node caching layers,
performance will be like the Azure SQL Database Business-Critical service tier, but with
the many other advantages the Hyperscale service tier has to offer.
334
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Summary of TPROC-C Workload Performance Results
As expected, we have similar schema build performance results for the Business Critical
and Hyperscale service tiers. However, the performance of the Hyperscale service tier
may vary and is heavily dependent on the type of workload being run. That difference
will be most noticeable during the TPROC-C workload execution. Table 12-21 shows
resource limits of Azure SQL Database deployments we used in these test examples and
their specifications comparison.
* Latency can vary and mostly depends on the workload and usage patterns. Hyperscale is a
multitiered architecture with caching at multiple levels. If data is being accessed primarily via a cache
on the compute node, latency will be similar as for Business Critical or Premium service tiers.
335
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
Table 12-22. Azure SQL Database TPROC-C Workload Performance Comparison
with 50 Warehouses and 32 Virtual Users to Build the Schema
Hammer DB GP_Gen5_8 BC_Gen5_8 HS_Gen5_8 HS_Gen5_8
TPROC-C (Scenario 1) (Scenario 2)
Workload
Total execution 10 (8 Timed Driver 10 (8 Timed Driver 10 (8 Timed Driver 10 (8 Timed Driver
time (minutes) Script option + 2 Script option + 2 Script option + 2 Script option + 2
minutes ramp-up) minutes ramp-up) minutes ramp-up) minutes ramp-up)
New orders 59112 130662 120896 100884
per minute
(NOPM)
Transactions 139351 308240 285210 238153
per minute
Peak 167670 362496 316650 276756
transactions
per minute
Summary
In this chapter, we talked about an overall performance comparison between the
traditional Azure architecture and Hyperscale architecture. We deployed and ran
benchmark tests against three different Azure SQL Database service tiers.
For benchmark tests, we used the TPROC-C OLTP workload implemented in the
HammerDB benchmark tool. The HammerDB TPROC-C workload is derived from
TPC-C and designed to be reliable and tuned to produce consistently repeatable and
accurate results. We compared schema build and PROC-C workload performance results
against all three deployments, hosting them all in the same Azure region and on the
same logical SQL server.
336
Chapter 12 TESTING HYPERSCALE DATABASE PERFORMANCE AGAINST OTHER AZURE SQL DEPLOYMENT
OPTIONS
In the following chapter, we will cover the basics of monitoring the performance
and health of a Hyperscale database. Also, we are going to explain how to adjust your
Hyperscale deployment tier to your ongoing workload requirements utilizing automatic
PaaS scaling ability.
337
PART III
Operation and
Management
CHAPTER 13
Tip All the features and settings outlined in this chapter can be implemented
using infrastructure as code. It is strongly recommended that for production
systems that you configure these via infrastructure as code once you’re familiar
with their operation. However, the examples in this chapter are limited to the Azure
Portal only for brevity.
341
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_13
Chapter 13 Monitoring and Scaling
The Metrics Explorer allows you to select one or more metrics to be displayed from
an available list that apply to the Hyperscale database resource. Some metrics can also
be filtered or grouped together to enable greater detail to be shown. For example, it is
possible to group by or filter the TLS version of the successful or failed SQL connections
metrics.
342
Chapter 13 Monitoring and Scaling
The following are some of the metrics that are currently emitted for a Hyperscale
database:
• Log storage metrics: These are storage metrics that relate to the use
of the SQL log and include Log backup storage size, Tempdb Log File
Size Kilobytes, and Tempdb Percent Log used.
Once you’ve configured a Metrics Explorer graph with the information you’re
interested in, you can pin this to an Azure Dashboard or send it to an Azure Monitor
Workbook using the “Save to dashboard” menu. Figure 13-2 shows the Pin to Dashboard
button in the “Save to dashboard” menu. This will save a live version of the graph to the
dashboard.
343
Chapter 13 Monitoring and Scaling
The platform metrics that are provided through this method are usually retained for
only 93 days. So, if you need to retain them for a longer period for reporting purposes or
if you need to combine these metrics with other diagnostic information, then you may
need to send these to a Log Analytics workspace.
4. Enter a name for the diagnostic setting in the “Diagnostic setting” box.
5. Select the “Send to Log Analytics workspace” box and select the
Log Analytics workspace to send the metrics to.
6. Select the checkbox for each type of metric you want to send to the
Log Analytics workspace.
7. Click Save.
Once the metrics are sent to the Log Analytics workspace, they can be queried and
visualized like any other data in the workspace. It is possible to combine the metrics
data with other diagnostic data in complex queries that can be used for visualization via
Azure Dashboards or Azure Monitor workbooks or alerting.
344
Chapter 13 Monitoring and Scaling
Important Sending metrics to a Log Analytics workspace incurs a cost, just like
sending diagnostic logs. To understand and managed costs of your Log Analytics
workspace, see https://learn.microsoft.com/azure/azure-monitor/
logs/analyze-usage.
The metrics that are sent to the Log Analytics workspace will land in the
“AzureMetrics” table. By default, data in this table will be retained for only 30 days. If you
want to retain the data for a longer period, you will need to set the retention period on
either of the following:
It is also possible to stream the metric logs to an Azure Storage account or Azure
Event Hub for either long-term storage and reporting or export into other systems.
• Email Azure Resource Manager role: This sends an email to all users
who have a specific RBAC role (e.g., owner) on the resource.
345
Chapter 13 Monitoring and Scaling
• Push: This sends a notification to the Azure mobile app for a single
user identified by their email address.
• Voice: This makes a phone call to a phone number and plays a
message. Currently only U.S. phone numbers are supported.
When the action group is executed, any defined actions will also be executed. The
following are the types of actions that can be executed:
• Automation Runbook: This executes either a PowerShell script or
Python contained in an Azure Automation Runbook. This can be a
good way to implement autoscaling on a Hyperscale database.
• Azure Function: This calls an Azure Function. This is another easy
way to implement autoscaling on a Hyperscale database.
• Event Hub: This sends a message to an Azure Event Hub.
To create a simple alert rule that sends an SMS message when the average workers
exceed 80 percent for 15 minutes, follow these steps:
1. In the Azure Portal, select a Hyperscale database resource.
346
Chapter 13 Monitoring and Scaling
You may notice that the preview window will show you a graph
of the metric over the last six hours and the threshold line as well
as highlighting anywhere over the period the metric crossed it.
Figure 13-3 shows the alert rule metric preview at 15 percent.
11. Actions groups can be used by more than one alert rule, so it is
common to create general-purpose action groups.
12. Specify the action group name and display name; in this case,
we’re setting these to Notify DBA.
347
Chapter 13 Monitoring and Scaling
22. Select the “Review + create” tab and click the Create button.
After a few seconds our alert rule will be created. Our DBA will now be sent an
SMS every five minutes that the average number of workers on the database exceeds
80 percent for 15 minutes. Figure 13-4 shows the SMS message received by our DBA
whenever the alert rule triggers.
Figure 13-4. The SMS message received when the alert rule triggers
348
Chapter 13 Monitoring and Scaling
This may get very annoying for our DBA. Thankfully, our DBA will receive an SMS
notifying them they’ve been joined to the Notify DBA group and that they can stop
notifications from this group. Figure 13-5 shows the SMS message that is received by any
mobile device in an action group.
Figure 13-5. The SMS message received by the action group members
If you find that you’re sending too many false positive notifications, consider using
a dynamic threshold for your alert rule. This will use machine learning algorithms
to continuously learn the metric behavior pattern and calculate the thresholds
automatically.
When the alert rule is triggered, a record in the Alerts tab displays the details of the
alert. Figure 13-6 shows the Alerts summary page for the Hyperscale database.
349
Chapter 13 Monitoring and Scaling
Clicking an individual alert shows the Alert Details page, which will show the details
of the metric conditions that caused the alert rule to trigger. Figure 13-7 shows part of the
Alert Details page indicating why the alert fired. In this example, the threshold was set to
15 percent.
Figure 13-7. Why did the alert fire on the Alert Details page?
Clicking the “Change user response” button for the alert can be used to indicate that
the alert has been acknowledged and responded to.
350
Chapter 13 Monitoring and Scaling
To review the Query Performance Insight tool in the Azure Portal, follow these steps:
3. Click the individual query rows to show the details of the query.
Query Performance Insight requires that Query Store is active on your database. It’s
automatically enabled for all Hyperscale databases by default, but if it is not, you’ll be
prompted to enable it when you open the tool.
It is recommended that you use this tool regularly to identify the top problematic
queries and review the recommendations that could be implemented to improve
performance.
Tip For more information on the Query Performance Insights tool, see
https://learn.microsoft.com/azure/azure-sql/database/query-
performance-insight-use.
351
Chapter 13 Monitoring and Scaling
Performance Recommendations
Built in to the Azure SQL Database services is the “Performance recommendations”
tool. This tool continuously analyzes and makes intelligent recommendations based on
recent query performance from your workload. The recommendations will identify the
following:
To review the performance recommendations in the Azure Portal, follow these steps:
Performing these tasks manually can become arduous, which is where the automatic
tuning can be very useful.
352
Chapter 13 Monitoring and Scaling
You can enable automatic tuning at the logical server level if you want and then set
the desired state to inherited to centralize the configuration of these settings.
Your Hyperscale database will now be automatically tuned with the options you’ve
selected. For more information on automatic tuning, see https://learn.microsoft.
com/azure/azure-sql/database/automatic-tuning-enable.
353
Chapter 13 Monitoring and Scaling
For example, to obtain wait statistics from the database, the sys.dm_db_wait_stats
view must be queried.
Since these DMVs are accessible only by connecting to the Hyperscale database and
running the query, it requires a lot of additional work to collect and report on them. To
simplify and automate the process of pulling the data from DMVs, a new preview feature
called SQL Insights is available.
This tool requires the deployment of an Azure virtual machine that runs a Collection
Agent. The Collection Agent collects one or more Hyperscale databases and pulls
the DMV data down and pushes it into a Log Analytics workspace. A single collector
machine can pull data from multiple Hyperscale databases.
Note SQL Insights supports not just Hyperscale databases. It can connect to and
query DMVs from any SQL deployment model in Azure.
Once SQL Insights has been set up to extract the DMV information into the Log
Analytics workspace, you can do the following:
At the time of writing, Azure SQL Insights is in preview. For more information about
SQL Insights, see https://learn.microsoft.com/azure/azure-sql/database/sql-
insights-overview.
SQL Analytics
The tools discussed so far in this chapter have been mostly focused on monitoring
individual Hyperscale databases. However, many larger environments have tens,
hundreds, or even thousands of SQL databases. They often have multiple different
deployment models for SQL, including both IaaS and PaaS. Therefore, it is useful to have
a single view of all the SQL resources across an entire environment. Azure SQL Analytics
provides this by collecting and visualizing key performance metrics with built-in
intelligence for performance troubleshooting.
354
Chapter 13 Monitoring and Scaling
Azure SQL Analytics is deployed as a solution into an Azure Log Analytics workspace.
To install the solution in the Azure Portal, follow these steps:
1. Enter Azure SQL Analytics into the search box at the top of the
Azure Portal.
2. Select the Azure SQL Analytics (Preview) entry under
Marketplace.
6. After a few seconds, the deployment will start. It should take only
a few seconds to deploy the solution. Once the deployment has
been completed, the solution will be available in the Log Analytics
workspace.
355
Chapter 13 Monitoring and Scaling
8. Clicking the Azure SQL Databases will show the SQL Analytics
dashboard for all Azure SQL Databases, including our Hyperscale
databases.
You can navigate through the SQL Analytics dashboard to review individual
databases. Figure 13-9 shows part of the SQL Analytics dashboard view of a single
Hyperscale database.
356
Chapter 13 Monitoring and Scaling
At the time of writing, Azure SQL Analytics is in preview, but you can find out
more information about it at https://learn.microsoft.com/azure/azure-monitor/
insights/azure-sql.
Note Before increasing the number of vCores on your SQL Hyperscale database,
you should first investigate query performance and investigate automatic tuning.
Once you’ve investigated these, you might decide that the only way to support the
workload demands is to increase the number of vCores assigned to the Hyperscale
database.
You may decide that you need to scale up the database by increasing the number of
vCores assigned to it. Scaling up (or down) the number of vCores is an online operation.
This means your Hyperscale database will remain operational throughout the process.
A new Hyperscale database engine will be provisioned with the desired number of
vCores, and once ready, a cutover will occur. Any open connections will be terminated,
and any uncommitted transactions will be rolled back with the cutover to the new
database engine.
Important You can expect a short connection break when the scale-up or
scale-down process is complete. If you have implemented retry logic for standard
transient errors, your workload won’t be impacted by the failover. However, you
should wait for any long-running transactions or operations to complete first.
It is also possible to scale out a Hyperscale database to add read replicas. These can
be either named replicas or high-availability secondary replicas. These replicas can be
used only to execute read operations.
357
Chapter 13 Monitoring and Scaling
Tip Because Hyperscale replicas in the same region share the underlying
storage infrastructure, the storage replication lag is near zero, which makes this
an attractive read scale-out option and one of the most important features of
Hyperscale. It is not completely zero because of the way Hyperscale leverages
Resilient Buffer Pool Extension caches (described in Chapter 2).
Leveraging read-scale out requires your workload to be designed to leverage it. This
usually means the workload is configured to send read operations to either of the following:
• A named replica with the SQL connection string specifying the logical
server and named replica database name.
• A high-availability secondary replica with the SQL connection string
containing ApplicationIntent=ReadOnly. These types of replicas
are primarily intended to enable high-availability but can be used for
read scale-out. If more than one high-availability replica is present,
the read-intent workload is distributed arbitrarily across all available
high-availability replicas.
If your workload can’t be changed to separate read operations in this way, then you
won’t be able to leverage scale-out, so increasing the number of vCores will be your
only option.
Both of these tasks can be performed in the Azure Portal or using code. Again,
leveraging declarative infrastructure as code is recommended.
Note that adding replicas does not force your workloads to reconnect to the
database, so it can be done easily.
To add a new named replica through the Azure Portal, follow these steps:
1. Select the Replicas blade in the Hyperscale database resource.
4. Select the Server (or create a new one) and configure “Compute +
storage” for the new replica.
6. Click Create.
After a few seconds, the new named replica will be created. It may take a few minutes
for the deployment to complete as new resources will be provisioned.
359
Chapter 13 Monitoring and Scaling
3. Click Apply.
Summary
In this chapter, we looked at the many tools and methods that should be used to
monitor a Hyperscale database. We reviewed the tools for monitoring and reporting on
the platform metrics emitted from the Hyperscale database. The options for sending
the platform metrics to a Log Analytics workspace for enhanced reporting scenarios
and increased retention were also examined. We reviewed the built-in tooling for
monitoring the query performance and automatically turning a Hyperscale database.
The SQL Insights feature is a way to provide a deeper level of monitoring on one or more
Hyperscale and other Azure SQL Database instances. SQL Analytics was discussed as a
way to monitor SQL at scale in Azure. Finally, the different approaches and methods of
scaling a Hyperscale database were highlighted.
In the next chapter, we will look at disaster recovery for a Hyperscale database as well
as backing it up and restoring it.
360
CHAPTER 14
Backup, Restore,
and Disaster Recovery
In the previous chapter, we covered the basics of monitoring the performance and
health of a Hyperscale database. We explained Hyperscale database’s manual and
automatically scaling features and showed how to scale to support different usage
patterns and workloads.
In this chapter, we will explain the advantages of Azure SQL Hyperscale deployments
in detail in the examples. We will cover fast database backup and restore operations and
explain why these operations provide some of the greatest advantages of Hyperscale
compared to other Azure SQL Database service tiers.
Tip Backups and restores do not have any I/O impact on the compute layer of
the Azure SQL Database Hyperscale service tier.
361
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_14
Chapter 14 Backup, Restore, and Disaster Recovery
Tip Differential backups are not supported for Azure SQL Hyperscale deployment.
Tip Short-term retention means the backups are available for 1 to 35 days.
At the time of writing, options for point-in-time restore (PITR) backup retention
periods of longer than seven days and long-term retention are available in preview.
Figure 14-2 shows the logical SQL Server instance backup retention policy
configuration pane.
362
Chapter 14 Backup, Restore, and Disaster Recovery
For the long-term backup retention policy configuration, you can specify the period
of time that weekly, monthly, and yearly long-term retention (LTR) backups will be
retained for. When the long-term backup retention policy is enabled, LTR backups will
be copied to a different Azure storage account for long-term retention. If you’re using
geo-replication, your backup storage costs for LTR won’t increase because your backups
are not produced by secondary replicas.
Tip For more information on the long-term retention of backups, see https://
learn.microsoft.com/azure/azure-sql/database/long-term-
retention-overview,
363
Chapter 14 Backup, Restore, and Disaster Recovery
Figure 14-3 shows the long-term backup retention policy configuration pane.
364
Chapter 14 Backup, Restore, and Disaster Recovery
365
Chapter 14 Backup, Restore, and Disaster Recovery
Not all Azure regions provide availability zone support. If you deploy your
Hyperscale database to a logical SQL Server instance located in a region without support
for availability zones, you will see only the options shown in Figure 14-4.
However, if your logical SQL Server instance is deployed to an Azure region that
supports availability zones, then you will see the options shown in Figure 14-5.
366
Chapter 14 Backup, Restore, and Disaster Recovery
Use one of the following metrics to review the backup storage consumption
information:
Figure 14-7 shows Azure Monitor data and log backup storage size metrics in the
Azure Portal.
367
Chapter 14 Backup, Restore, and Disaster Recovery
368
Chapter 14 Backup, Restore, and Disaster Recovery
In addition, for Hyperscale databases there two other factors that may affect the
performance of the restore operation.
In the next five examples, we will review the Hyperscale database restore
performance to provide more insight into how each of these factors affects restore time.
We will use a combination of different database sizes, Azure regions, and backup storage
redundancy types.
Tip Even though these tests are real examples, the results may vary slightly
across different Azure regions at various times of the day. Your own tests may
differ slightly.
369
Chapter 14 Backup, Restore, and Disaster Recovery
Figure 14-8 shows restore time for the Hyperscale database tpcc_hs with a used
space of 9.21GB and an allocated space of 20GB.
Figure 14-8. Restore time for a Hyperscale database (10GB size) from LRS to LRS
If we double the size of the database, the restore still shows similar performance
results. Figure 14-9 shows the restore time for the Hyperscale database tpcc_hs with a
used space of 20.4GB and an allocated space of 30GB.
Figure 14-9. Restore time for a Hyperscale database (20GB size) from LRS to LRS
If we triple the size of the database, we are still getting similar results. Figure 14-10
shows the restore time for the Hyperscale database tpcc_hs with a used space of
71.99GB and an allocated space of 120GB.
Figure 14-10. Restore time for a Hyperscale database (70GB size) from LRS to LRS
From the first example, we can see that the restore operations for Hyperscale
databases are almost as fast regardless of the data size if we are using the same backup
storage redundancy within the same region.
370
Chapter 14 Backup, Restore, and Disaster Recovery
Figure 14-11 shows the Hyperscale database tpcc_hs with two page servers
managing the data files, with the biggest data file size as 80GB (growth in 10GB
increments) and with an allocated space of 120GB.
If we restore the same Hyperscale database as before, using the same region and
the same logical SQL Server instance for the source and destination but restoring to
a destination database that has GRS backup storage redundancy, the restore will take
longer than in the previous example. This is because we are changing the redundancy
type for our destination backup storage from locally redundant to geo-redundant.
Figure 14-12 shows the restore-time performance for the Hyperscale database tpcc_hs
with two page servers managing data files, with the largest data file size of 80GB, a used
space of 71.97GB, and an allocated space of 120GB.
Figure 14-12. Hyperscale database restore time with the same logical SQL Server
instance, from LRS to GRS
371
Chapter 14 Backup, Restore, and Disaster Recovery
In the case of reallocating your database to geo-redundant storage, all the data files
will be copied in parallel. This causes the restore operation to take longer.
Figure 14-13 shows the restore-time performance for the Hyperscale database tpcc_
hs with two page servers managing data files, with the largest data file size of 80GB, a
used space of 71.97GB, and an allocated space of 120GB.
Figure 14-13. Hyperscale database restore time to the same logical SQL Server
instance, from GRS to GRS
372
Chapter 14 Backup, Restore, and Disaster Recovery
Figure 14-14 shows geo-restore time performance for the Hyperscale database
tpcc_hs with two page servers managing data files, with the largest data file size of 80GB,
a used space of 71.97GB, and an allocated space 120GB.
Figure 14-14. Hyperscale database geo restore time to a different Azure region,
from GRS to LRS
Tip In the case of geo-restore operation, your source database always must be
on geo-redundant backup storage.
373
Chapter 14 Backup, Restore, and Disaster Recovery
Note In the case of geo-redundant storage and geo-restore, all data files will be
copied in parallel, and the restore operation duration will depend on the size of the
largest database file.
Table 14-1 and Table 14-2 compare the restore times for the restore and geo-restore
operations for the same database. For these examples, a Hyperscale database with two
page servers managing data files, with the largest data file size of 80GB, a used space of
71.97GB, and an allocated space of 120GB.
Table 14-1. Hyperscale Database Restore Within the Same Azure Region
Performance Table
Restore Time Within Same Region, Same Logical SQL Server
Backup Storage Redundancy Types LRS GRS
LRS 6 minutes 58 seconds 23 minutes 32 seconds
GRS 26 minutes 34 seconds 5 minutes 4 seconds
Table 14-2. Hyperscale Database Restore Within the Same Azure Region
Performance Table
Geo-restore Time to a Different Region
Backup Storage Redundancy Types LRS GRS
GRS 25 minutes 27 seconds 36 minutes 19 seconds
As we can see, changing the backup storage redundancy has a significant impact on
restore time, as does performing a geo-restore operation.
374
Chapter 14 Backup, Restore, and Disaster Recovery
Figure 14-16. Page server file sizes in the Hyperscale database deployment
The total time of the restore process should be the time necessary to restore the
largest data file, in this case 100GB. Figure 14-17 shows the restore performance of a
Hyperscale database with data file sizes of 100GB, 97GB, and 20GB with the used space
of 174.42GB and an allocated space of 217.45GB.
375
Chapter 14 Backup, Restore, and Disaster Recovery
Figure 14-18 shows the restore performance of a General Purpose service tier
database with data file sizes of 100GB, 97GB, and 20GB with a used space of 174.42GB
and an allocated space of 217.45GB.
The last step was to scale the same database to the Business Critical service tier
and then evaluate the restore process again. Once scaling was completed, a database
restore was performed to the same logical SQL instance. Figure 14-19 shows the restore
performance of the Business Critical service tier database with the data file sizes of
100GB, 97GB, and 20GB with a used space of 174.42GB and an allocated space of
217.45GB.
If we compare the performance for the same size database between different Azure
SQL service tiers, we can clearly see that the Hyperscale restore performance surpasses
both the General Purpose and Business Critical restore operations.
376
Chapter 14 Backup, Restore, and Disaster Recovery
Disaster Recovery
If you use geo-redundant storage to store your backups, you may use a geo-restore
option as a disaster recovery solution for your Hyperscale database. In this case, you can
restore your Hyperscale database to a different region as part of your disaster recovery
strategy.
Note The geo-restore option is available only when you are using geo-redundant
storage as your backup storage redundancy.
Figure 14-20 shows an example of a geo-restore using the Azure Portal to restore the
most recent geo-replicated backup.
377
Chapter 14 Backup, Restore, and Disaster Recovery
Figure 14-20. Azure Portal create database from most recent geo-
replicated backup
Another disaster recovery option for the Azure SQL Database Hyperscale service tier
is active geo-replication. With the availability of the geo-replica option in the Hyperscale
architecture, we can have a readable secondary replica in the same region or a different
region. If a geo-replica is in a different region, it can be used for disaster recovery as a
failover in the case of a regional outage of the primary region. Figure 14-21 shows an
example of the forced failover to a secondary geo-replica.
378
Chapter 14 Backup, Restore, and Disaster Recovery
Figure 14-21. Geo-replica restore example with geo-replica forced failover option
Summary
In this chapter, we covered the Hyperscale database file snapshot backup process and
talked about advantages of this when compared with a traditional database backup
process. We also discussed how Hyperscale achieves a fast restore. We talked about these
different backup storage redundancy options:
379
Chapter 14 Backup, Restore, and Disaster Recovery
380
CHAPTER 15
381
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_15
Chapter 15 Security and Updating
Figure 15-1 shows the Azure SQL database security strategy of securing our sensitive
data tier.
Some of the security features are easily accessible upon deploying a logical SQL
Server instance through the Azure Portal. Figure 15-2 shows some of the server-level
security features easily available through the Azure Portal security pane.
382
Chapter 15 Security and Updating
Figure 15-2. Azure SQL logical server security features in the Azure Portal
Database-level security features available through the Azure Portal might look a bit
different. Figure 15-3 shows some additional database-level features such as dynamic
data masking and the Ledger. The Ledger is a powerful feature that keeps an immutable
and tamper-proof history of all transactions executed against the tables. This provides
the ability to compare data with the historical values kept by the Ledger and digitally
verify that it is correct.
383
Chapter 15 Security and Updating
Network Security
After a logical SQL Server instance is deployed, it is recommended to restrict network
access and allow only limited access to a database. This can be done using the Azure
Portal. It is recommended to configure firewall and virtual network rules and explicitly
allow connections only from selected virtual networks and specific IP addresses.
384
Chapter 15 Security and Updating
Some of the usual firewall and virtual network rules configuration use case scenarios
may include but not be limited to the following:
385
Chapter 15 Security and Updating
• Firewall rules allow public access to your resources only for the
specified Internet IP addresses.
You can specify some networking rules during Azure SQL database deployments as
well, including creating private endpoints for your Azure SQL deployment. Chapter 4
covered a demonstration of connecting a Hyperscale database to a virtual network.
Figure 15-6 shows a firewall rules configuration option during the Azure SQL Database
deployment process.
Figure 15-6. Configuring firewall rules for an Azure SQL logical server during
deployment
Connection Policy
Define how your clients connect to your logical SQL server and access your Azure SQL
database.
386
Chapter 15 Security and Updating
Figure 15-7 shows the logical SQL Server connection policy configuration shown on
the SQL Server ➤ Security ➤ Networking ➤ Connectivity blade.
Access Management
Through access management, we manage users and their permissions, as well
as verifying the user’s identity. When we or one of our workloads connects to a
logical server, we can choose to use SQL authentication or Azure Active Directory
authentication. If we are using Azure Active Directory authentication, then we can
authenticate as a user or a service principal.
387
Chapter 15 Security and Updating
• Only SQL authentication: Use this only if your workloads and tooling
don’t support Azure AD authentication.
Figure 15-8 shows the available logical Azure SQL Server authentication methods.
388
Chapter 15 Security and Updating
• SQL Server Contributor: You can manage SQL servers and databases
but not connect to them or to their security-related policies.
Note It is possible to create custom RBAC roles that allow or deny specific
permissions on the built-in roles, but it is recommended to follow best practices by
ensuring the principle of least privilege is being used.
Configuring whether a user can connect to the logical server is done by setting
permissions in the database engine. For more information on this, see https://learn.
microsoft.com/sql/relational-databases/security/authentication-access/
getting-started-with-database-engine-permissions.
Tip In Azure, RBAC can be used to govern the permissions both on the control
plane to the resource and on the data plane. The data plane consists of the
permissions you require to access the data a resource contains. In the case of
Azure SQL Database and logical servers, all data plane access is configured by
defining the permissions in the database engine, not via RBAC roles.
389
Chapter 15 Security and Updating
Row-Level Security
Row-Level Security (RLS) is a security mechanism that limits access to rows in a
database table based on the logged-in user. This ensures that the logged-in user can only
read and write to specific records in each table, based on their permission.
390
Chapter 15 Security and Updating
Figure 15-9 shows the Azure SQL logical server-level auditing settings in the SQL
Server ➤ Security ➤ Auditing blade.
Figure 15-9. Configuring auditing on the logical server in the Azure Portal
Tip You can enable auditing on the server level or the database level. If Azure
SQL Server auditing is enabled, it will overwrite the database-level settings, and
the database will be audited, ignoring the database auditing settings.
391
Chapter 15 Security and Updating
Information Protection
In the Information Protection category, we can review all the security features involved
with encrypting data both at rest and in use, as well as encrypting connections and
masking sensitive data in our Azure SQL deployment.
Bear in mind that there is no user action necessary to maintain the certificate behind
the encryption key, as this is managed by the service, including certificate rotation.
Nevertheless, if customers insist on having full control of their encryption keys, they
have an option to do so. With bring your own key (BYOK) for TDE, customers can take
ownership of key management, including key certificate maintenance and rotation. This
was also discussed in Chapter 6.
393
Chapter 15 Security and Updating
Tip Even users with elevated permissions and access to your data such
as database administrators will not be able to see sensitive data without the
correct encryption key. For more information on enabling Always Encrypted,
see https://learn.microsoft.com/sql/relational-databases/
security/encryption/always-encrypted-database-engine.
Data Masking
If you want to prevent users from seeing sensitive data, you might consider using
dynamic data masking. This feature enables you to create masking rules and avoid
exposure of sensitive data to particular users. Figure 15-13 shows the database-level
blade found at SQL Database ➤ Security ➤ Dynamic Data Masking.
Within the masking rule you can specify schema, table, and column names with a
masking field format. Figure 15-14 shows adding a masking rule page, with the schema,
table, and column as requested fields.
394
Chapter 15 Security and Updating
Additionally, the dynamic data masking feature can recognize fields storing
potentially sensitive data and automatically recommend those fields to be masked.
Figure 15-15 shows the recommended fields to mask.
395
Chapter 15 Security and Updating
If masking is enabled for a specific column and a SQL query is executed against that
column, you will be able to see only the masked sensitive data in the query results set,
while at the same time the data in the database is unchanged.
396
Chapter 15 Security and Updating
If you choose a region that does not support configuring the maintenance window, it
will look like Figure 15-17.
Figure 15-17. Setting the maintenance window not supported in this region
Tip Bear in mind that maintenance windows are there to ensure that all planned
upgrades or maintenance tasks happen within a particular time range. This will not
protect your database resource from any unplanned regional or zonal outages.
397
Chapter 15 Security and Updating
Summary
In this chapter, we looked at some of the best practices of securing the data tier in Azure
SQL deployments. We covered different Azure SQL database security strategies for how
to prevent any access to the server and the customer’s sensitive data until that access
is explicitly granted. We explained the roles of multiple security layers between the
network traffic and customer data. We covered network security, access management,
auditing, and threat protection and information protection.
In the next chapter, we will talk about how to optimize the total cost of operating the
Hyperscale environment.
398
CHAPTER 16
Managing Costs
Over the previous few chapters, we’ve looked at many of the management and
operational tasks required to ensure resilient, performant, and secure operation of a
Hyperscale environment. Another important management task is the need to review and
optimize costs.
Most organizations want to know that they’re getting the best value for their
investment and require regular review of ongoing costs to ensure this. In this chapter,
we will look at how we can optimize the total cost of ownership (TCO) of the Hyperscale
environment. We will look at the different options available to tune the cost of operating
the Azure SQL Database Hyperscale.
399
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_16
Chapter 16 Managing Costs
If you qualify for AHB, you can enable this discount when deploying your Hyperscale
database through the Azure Portal.
• For new databases, during creation, select “Configure database” on
the Basics tab and select the option to save money.
You can also configure this using Azure PowerShell, the Azure CLI, or Azure Bicep,
but for the sake of brevity we will not cover those methods here. For more information
on Azure Hybrid Benefit, see https://learn.microsoft.com/azure/azure-sql/azure-
hybrid-benefit.
400
Chapter 16 Managing Costs
Reserving Capacity
One of the simplest methods of reducing costs is to leverage reserved capacity. This
allows you to commit to using a specified number of vCores on a Hyperscale database
in a specified Azure region for either a 1- or 3-year period. This can provide a significant
discount on the cost of running a Hyperscale database.
2. Click Add, and then in the Purchase Reservations pane, select SQL
Database to purchase a new reservation for Hyperscale.
5. Click Purchase.
401
Chapter 16 Managing Costs
Utilizing Reservations
Once capacity has been reserved for an Azure region and Hyperscale tier, any Hyperscale
database created that matches the scope of any existing reservations will automatically
be assigned to use the reservation if there are unutilized vCores in the reservation.
Deleting or scaling down a Hyperscale database in the region will return the vCores back
to the reservation to be utilized by another Hyperscale database.
It is a good idea to regularly review the utilization of reserved capacity to ensure
you’re utilizing the capacity you have reserved. To review reserved capacity utilization in
the Azure Portal, follow these steps:
402
Chapter 16 Managing Costs
1. Enter Reservations in the search box at the top of the Azure Portal
and select Reservations.
2. The list shows all the reservations where you have the Owner or
Reader role. Each reservation displays the last known utilization
percentage.
3. Click the utilization percentage to see the details of the reservation
and its history.
For more information on reviewing the utilization of your reservations, see https://
learn.microsoft.com/azure/cost-management-billing/reservations/reservation-
utilization.
403
Chapter 16 Managing Costs
For example, in a retail services environment, the primary database may be used
24 hours a day, but report generation is scheduled as a batch process that runs daily,
starting at 1 a.m., and takes roughly four hours. This means the replica could be scaled
down or scaled in for 20 hours a day, reducing the compute costs.
Important You should perform only regular scaling operations to tune costs
on named replicas. High-availability secondary replicas or geo replicas are not
typically used for this purpose. High-availability secondary replicas are intended to
be used for high availability and will always have the same number of vCores as
the primary database. A geo replica used for failover should always have the same
number of vCores as the primary replica.
The following are some common scaling methods of leveraging replica scaling to
reduce cost:
• Scale-in: Remove the replica when not in use. For example, if batch
reporting or data export processes are required to run only between
the hours of 1 a.m. and 5 a.m., then the named replica can be deleted
entirely. Removing a replica will delete the compute associated
with it, but not the underlying storage, which is part of the primary
database.
404
Chapter 16 Managing Costs
Important You should ensure that any workloads that utilize the replica will
be able to handle the scale operations that you’re performing. For example, a
workload that doesn’t implement retry logic for standard transient errors will
experience errors with scale-up and scale-down operations. Any long-running
transactions will also be terminated, so your workload should ensure these are
completed.
It is also worth considering the TCO for implementing the scaling methodology.
When factoring in time to build, monitor, operate, and maintain the infrastructure to
enable a replica scaling methodology, this may not result in a net benefit.
Summary
In this chapter, we looked at some of the most common ways to reduce the cost of a
Hyperscale environment.
In the next chapter, we will look at some common patterns, use cases, and workloads
that can benefit from Hyperscale, beyond the increased storage capacity.
405
PART IV
Migration
CHAPTER 17
Determining Whether
Hyperscale Is Appropriate
In the previous chapter, we focused on how to better understand and optimize the costs
of the Hyperscale environment. We covered a few of the most effective ways to reduce
and tune the operating costs of an Azure SQL Hyperscale database.
The goal of this chapter is to ease the business decision of whether migrating to an
Azure SQL Hyperscale database will be the best solution for your production workload.
We will cover the various advantages of the Azure SQL Hyperscale architecture
compared to other Azure SQL platform-as-a-service (PaaS) deployments.
409
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_17
Chapter 17 Determining Whether Hyperscale Is Appropriate
• Cost: What is the cost of running Hyperscale, and how will this
change as my solution grows? The cost of Hyperscale is primarily
affected by the number of vCores consumed by the primary and
secondary replicas and the amount of storage used. Several other
factors also affect this.
Scalability
Every successful business can thrive only when there are either no scalability limitations
or when limits are flexible enough to support future growth. The scalability of your
workload can be significantly increased when using fully managed Hyperscale database
solutions.
The ability to assign more resources dynamically when necessary is one of the
biggest benefits of the fully managed cloud database services. All Azure SQL PaaS
deployment options can be easily and dynamically scaled to meet your needs. Azure
SQL enables you to adjust performance characteristics by allocating more resources to
your databases, such as CPU power, memory, I/O throughput, and storage.
By introducing the Hyperscale architecture, your workload can achieve a level
of scalability that is not met by any other Azure SQL deployment. One of the main
characteristics of the Hyperscale architecture, the decoupling of remote storage and
compute tier, makes vertically scaling resources such as CPU and memory a fast and
seamless process and is independent of the size of the database.
410
Chapter 17 Determining Whether Hyperscale Is Appropriate
When looking at your scalability needs, you should consider the following:
• How will your compute and storage requirements change over time,
and will you reach the limits of the service tiers?
411
Chapter 17 Determining Whether Hyperscale Is Appropriate
* You may consider using high-availability replicas for read scale-out scenarios. Nevertheless, you can
create up to 30 named replicas suitable for more complex read scale-out scenarios.
412
Chapter 17 Determining Whether Hyperscale Is Appropriate
Reliability
All Azure SQL database deployments, including the Hyperscale service tier, are fully
managed PaaS database engines. This means that maintenance activities such as
patching and upgrading happen automatically and are managed by Microsoft Azure.
They are always updated with the latest stable SQL Server version and provide at least
99.99 percent availability guarantee. The inclusion of built-in redundancy, regardless of
the Azure SQL deployment option chosen, makes an Azure SQL PaaS database solution
reliable, highly available, and resilient to outages. Table 17-2 shows the reliability
features of the different service tiers of Azure SQL Database.
Business Continuity
All Azure SQL Database deployment options have built-in redundancy. There are several
factors to be aware of when considering business continuity.
• Service redundancy: This refers to the redundancy of the database
and includes high-availability replicas and geo replicas.
413
Chapter 17 Determining Whether Hyperscale Is Appropriate
414
Chapter 17 Determining Whether Hyperscale Is Appropriate
Backup Full backups every week. Full backups every week. Backups are based on
frequency Differential backups every Differential backups every storage snapshots of
12 or 24 hours. 12 or 24 hours. data files.
Transaction log backups Transaction log backups
approximately every 10 approximately every 10
minutes.** minutes.**
Backup 1–35 days (7 days by 1–35 days (7 days by 1–35 days (7 days by
retention policy default). default). default).
Backup storage Locally redundant backup Locally redundant backup Locally redundant
redundancy storage. storage. backup storage.
Zone-redundant backup Zone-redundant backup Zone-redundant backup
storage.* storage.* storage.*
Geo-redundant backup Geo-redundant backup Geo-redundant backup
storage. storage. storage.
Geo-zone redundant
backup.
Restore ability Restore time depends on Restore time depends on Fast restore time
database size. database size. regardless of database
size.***
* Zone-redundant backup storage is available only in specific Azure regions that have multiple
availability zones. Each availability zone represents a separate data center with independent
hardware infrastructure.
** The frequency of transaction log backups may vary depending on the amount of database activity.
*** The restore process of a Hyperscale database within the same Azure region is not a size-
dependent operation. Nevertheless, geo restores will take more time to finish.
It is possible to achieve very high levels of availability and almost instant recovery
from zonal or regional failures with the right design, but these will usually increase the
cost of the solution.
415
Chapter 17 Determining Whether Hyperscale Is Appropriate
Cost
When determining the total cost of ownership of using a Hyperscale database, it is
important to consider both the Azure costs of the service as well as the operational
savings of using a managed PaaS service. In this section, we’ll focus on the Azure costs
of running a Hyperscale database, but it is equally important to assess the operational
savings you will make through reducing the time taken to maintain, patch, and operate
the underlying infrastructure.
Tip Ensure you’re factoring in any cost savings that you might be able to
leverage, as discussed in Chapter 16.
The following factors affect the Azure cost of running a Hyperscale database:
• Number of vCores: The number of vCores will affect both the primary
database and any HA replicas as they always match. Named and geo
replicas can have a different number of vCores assigned. These may
be able to be scaled dynamically to reduce costs depending on your
workload and architecture.
• Number of replicas: Consider the number of HA replicas, named
replicas, and geo replicas you will be deploying. These may be able to
be scaled dynamically to reduce costs depending on your workload
and architecture.
• Database storage: The amount of data stored in the database affects
the cost of the database and the amount of backup storage required.
This is likely to grow over time, so it is important to consider how this
will change.
416
Chapter 17 Determining Whether Hyperscale Is Appropriate
• LTR backup storage: Consider the amount of storage required for LTR
backups.
• Microsoft Defender for SQL: If you are using Microsoft Defender for
SQL, this will incur an additional monthly cost.
• Related services: There may be other costs that are incurred by your
environment, such as Azure Key Vaults, network bandwidth, virtual
networking, and related services. It is important to consider these
costs as well.
417
Chapter 17 Determining Whether Hyperscale Is Appropriate
With these factors you can reasonably accurately forecast the cost of operating a
Hyperscale environment.
Tip It is strongly recommended that you leverage the Azure Pricing Calculator
to produce a forecast of costs for your Hyperscale database, replicas, and related
services (Log Analytics workspaces). You can find the Azure Pricing Calculator at
https://aka.ms/AzurePricingCalculator.
Summary
In this chapter, we weighed all the benefits of choosing Hyperscale compared to
traditional Azure SQL architecture. We discussed the determining factors for that
decision such as higher performance, easier scalability, and higher reliability. Some of
the key features include the following:
In the next chapter, we will review some of the ways to migrate an existing workload
to Azure SQL Hyperscale. This will include an overview of the different tools available as
well as how to use them.
418
CHAPTER 18
Migrating to Hyperscale
In the previous chapter, we looked at the types of workloads that would benefit from or
require the use of the Azure SQL Database Hyperscale tier. Now that we’re familiar with
when Hyperscale will be a good fit for you, we need to review the processes required to
migrate an existing database into Hyperscale.
This chapter will walk you through the different migration scenarios and identify
the migration options available for each. Any database migration should be approached
with care, so planning and testing are always recommended. We will run through
some approaches that can be used to evaluate Hyperscale with our workload before
performing a production migration.
We will cover the various methods and tools available to migration from different
source database types as well as review the recommended use cases for each one.
Regardless of your chosen migration method, there will always be a point that any
SQL connections must be terminated and reconnected to the new instance. It is good
practice to design your workload to be able to handle transient connection issues with
retry logic, as this will make these sorts of migrations simpler.
419
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_18
Chapter 18 Migrating to Hyperscale
During a migration, the availability of your database will usually be affected. How the
availability will be impacted is defined by the following:
• Online: The database will remain available for the workloads during
the entire process with only a small cutover period at the end.
The following are the migration approaches that we are going to cover in the
remainder of this chapter:
• Azure Data Studio (ADS) with Azure SQL Migration extension: This
leverages an instance of the Azure Data Migration Service to perform
the migration. It effectively provides an alternate interface to create
and monitor a migration project in a DMS resource.
• Data sync and cutover: This is a more generic migration that uses
various tools and technologies to sync or replicate the content of the
database and then cut over to the new database once the data has
completed syncing.
Choosing the method of migration will depend on a combination of these factors.
420
Chapter 18 Migrating to Hyperscale
Table 18-1. Available Methods for Migrating to the Azure SQL Database
Hyperscale Tier
Migration Method From an Azure From an Azure SQL From Microsoft
SQL Database Managed Instance SQL Server1
Note It is also possible to migrate from AWS RDS for SQL Server using the Azure
Database Migration Service.
1
This includes on-premises SQL Server, SQL Server hosted on other cloud providers, and SQL
Server on Azure VMs.
2
In-place conversion to a Hyperscale database with availability zones is not currently supported.
Online migration is performed, but a short outage occurs.
3
Azure DMS can perform only an offline migration to Azure SQL Database.
421
Chapter 18 Migrating to Hyperscale
You can use the in-place conversion method to convert from any of the following
Azure SQL Database tiers and configurations:
• Basic
• Standard
• Premium
Behind the scenes, when you perform an in-place conversion, Azure will create a
new database for you with the desired Hyperscale tier and copy the existing data to the
new database. This may take several hours depending on the amount of data in your
database and how frequently writes are occurring. Once all the data in the database has
been copied, the old database will be taken offline. Any changes to the original database
that occurred since the beginning of the copy process will be replayed to the new
database. The new database will be brought online in place of the old database.
Tip To minimize the amount of time the database is offline during the final replay
process, reduce the number of writes to the database. Consider performing the
conversion at a time of lower write frequency.
Because this process creates a new Hyperscale database and copies the existing
schema and data into it, we can convert from any Azure SQL Database tier and
configuration. However, we cannot perform an in-place conversion from Azure SQL
MI or SQL Server on an Azure VM to Hyperscale in this way because of the significant
platform differences between the two.
Important Before you can convert an existing Azure SQL Database instance to
the Hyperscale tier, you must first stop any geo-replication to a secondary replica.
If the database is in a failover group, it must be removed from the group.
422
Chapter 18 Migrating to Hyperscale
Let’s make a copy of an existing Azure SQL Database in either the same logical server
or a different one. You can perform this task using the Azure Portal, Azure PowerShell, or
the Azure CLI. To copy an Azure SQL Database in the Azure Portal, follow these steps:
2. Click Copy.
3. Set the database name to the name of the new database copy.
The database will be copied and attached to the chosen logical server. We can then
perform an in-place conversion to Hyperscale of the copy and verify the workload
performance.
423
Chapter 18 Migrating to Hyperscale
5. Click Apply.
Your database will be migrated to Hyperscale. This may take several hours to
complete if you have a lot of data in the existing database. It will also go offline at the end
for a few minutes while any changed data is replicated.
You can also convert an Azure SQL Database to Hyperscale using Azure PowerShell,
Azure CLI, or Transact-SQL, or by updating your declarative infrastructure as code files
(Azure Bicep, Terraform).
424
Chapter 18 Migrating to Hyperscale
You should install the DMS onto a machine that meets the following requirements:
• Has TCP 1433 access to both the source SQL Server and the
Hyperscale database
If your source SQL Server is on-premises, you’ll typically need to create a networking
topology that will support your organizing needs, and many organizations will require
that the data is not migrated over the public Internet. There are many different network
topologies that could be used to enable this connectivity. We won’t cover them here as
they are beyond the scope of this book.
425
Chapter 18 Migrating to Hyperscale
The first step of migrating a SQL database using DMS is to perform an assessment to
identify any incompatibilities.
1. Start the Data Migration Assistant.
5. The source server type should be SQL Server, and the target server
type should be Azure SQL Database.
426
Chapter 18 Migrating to Hyperscale
6. Click Create.
7. Select both “Check database compatibility” and “Check feature
parity” and click Next.
427
Chapter 18 Migrating to Hyperscale
11. The results of the assessment will be displayed after a few seconds.
Figure 18-1 shows part of the assessment results screen showing the unsupported
features that might impact the workload if migrated to Hyperscale. In our demonstration,
these features are not needed, so we can safely ignore this.
Figure 18-1. Partial output from an assessment of SQL Server to an Azure SQL
Database
Once we’ve performed an assessment and determined that our source database and
Hyperscale are compatible, then we can perform the migration.
2. Set the project type to Migration and specify a name for the
project.
3. The source server type should be SQL Server, and the target server
type should be Azure SQL Database.
428
Chapter 18 Migrating to Hyperscale
5. Click Create.
7. After a few seconds, the list of databases that can be migrated will
be displayed. Select the source database you’d like to migrate from
and click Next.
8. Configure the “SQL Server connection settings” in the “Connect to
target server” page and click Connect.
429
Chapter 18 Migrating to Hyperscale
10. The list of objects that you can migrate will be displayed. You can
select each to review any issues with the migration or deselect it to
omit it from the migration.
11. Click “Generate SQL script” to create the script to create the
schema in the target.
12. The schema script will be displayed. You can edit this before
deploying and step through any identified issues. Click “Deploy
schema” when you’re ready.
13. Once the schema has deployed, click the “Migrate data” button.
14. You will see a list of tables available for migration along with the
number of rows for each and whether they are ready to migrate.
Select the tables you want to migrate.
430
Chapter 18 Migrating to Hyperscale
16. The data will be migrated, and the migration summary will be
displayed.
Figure 18-2 shows an example of the migration summary screen from DMS.
The time taken to perform the migration will depend on the volume of data to be
migrated as well as a few other factors.
431
Chapter 18 Migrating to Hyperscale
When you perform a data migration using the Azure Data Migration Service, it
assumes the target database schema already exists. There are multiple ways you might
have achieved this. One way is to use the Microsoft Data Migration Assistant schema
migration, as documented earlier in this chapter.
432
Chapter 18 Migrating to Hyperscale
Unlike other migrations where you are leveraging compute that you deploy and
manage for the task, the DMS provisions and manages this for you, providing the
supporting infrastructure required to perform the migration. When you deploy the DMS
into Azure, it is deployed into an Azure VNet. It will be your responsibility to ensure that
the DMS service is able to connect to the source and target databases.
There are two DMS tiers to choose from when you’re deploying.
• Standard: Use this for large data sizes and with one, two, or four
vCores allocated. It supports offline migrations only.
At the time of writing, both the Standard and Premium tiers of DMS are free for the
first six months of use.
433
Chapter 18 Migrating to Hyperscale
• If you are using any firewalls between DMS and your databases, you
will need to ensure that TCP port 1433 can traverse them.
With these requirements in mind, there are many different architectures and
networking technologies that could be used to implement this. Figure 18-3 shows an
example.
ExpressRoute
or VPN
Private
endpoint
Gateway Database Hyperscale
SQL Server TCP 1433 TCP 1433
Migration Service Database
434
Chapter 18 Migrating to Hyperscale
435
Chapter 18 Migrating to Hyperscale
3. Click + Create.
4. Set the source server type to SQL Server and the target server type
to Azure SQL Database.
7. Select the subscription and resource group you want to create the
DMS resource in.
8. Enter a name for the DMS resource into the “Migration service
name” field.
9. Set the location to the same region your target database is in.
436
Chapter 18 Migrating to Hyperscale
11. Select Standard and select the number of vCores allocated to the
DMS service. If you were intending on using this DMS resource
to also perform online migrations (where supported), then you
could select Premium. The more vCores assigned to the DMS
service, the greater the performance of any migration projects
running on it.
12. Click Apply.
It will take a minute or two to deploy the Azure Data Migration Service as well as the
virtual network adapter that is required to connect it to the virtual network.
437
Chapter 18 Migrating to Hyperscale
Important Before using DMS to migrate your database, you should always use
the Microsoft Data Migration Assistant to perform an assessment on the source
database for any issues that might cause migration problems or prevent your
workload from operating correctly in an Azure SQL Database. Using Data Migration
Assistant is documented earlier in this chapter.
There are several ways to create and run the DMS migration project.
• Using Azure Data Studio and the Azure SQL Migration extension
In this chapter, we will focus on the Azure PowerShell method of using DMS. We will
briefly touch on using the Azure Data Studio with Azure SQL Migration.
Tip If you want to know how to use DMS to perform a migration using
PowerShell, see https://learn.microsoft.com/azure/dms/howto-sql-
server-to-azure-sql-powershell.
To create a new migration project in DMS using the Azure Portal, then follow
these steps:
438
Chapter 18 Migrating to Hyperscale
3. Set the project name to a unique name for the migration project.
4. Set the source server type to SQL Server and the target server type
to Azure SQL Database.
6. Click “Create and run activity.” This will create the migration
project and open the SQL Server to Azure SQL Database Migration
Wizard, as shown in Figure 18-5.
Figure 18-5. The SQL Server to Azure SQL Database Migration Wizard
439
Chapter 18 Migrating to Hyperscale
8. Click Next to select the databases to migrate from the source SQL
Server. DMS will estimate the expected downtime to migrate each
database based on several factors including target database SKU,
source server performance, and network bandwidth.
9. Click Next.
10. Configure the settings to connect to the target SQL logical server.
11. Click Next to map the source database to the target database.
440
Chapter 18 Migrating to Hyperscale
12. Select the target database from the drop-down for each source
database. Selecting the check box next to each database mapping
will cause the source database to be set to read-only once the
migration starts. This is recommended to ensure no data is
changed after the migration begins.
13. Click Next to configure the tables to copy from the source to the
target. These tables must already exist in the target; otherwise,
they will not be able to be selected for migration.
16. Click “Start migration.” If you checked the box to make the source
database’s read-only once migration begins, this will occur now.
17. The migration will begin, and the status of the migration activity
will be displayed. Figure 18-6 shows an example of the migration
activity status.
441
Chapter 18 Migrating to Hyperscale
You can review the migration details of each table by clicking the database
record in the migration activity status page.
18. Once the migration has been completed, you can then delete any
unneeded resources, such as the migration project, migration
activity, and the DMS resource itself.
Now that the database migration has been completed, you can reconfigure any
workloads to connect to the new Hyperscale database.
442
Chapter 18 Migrating to Hyperscale
Tip To learn more about Azure Data Studio, please visit http://aka.ms/
azuredatastudio.
Using this method provides an alternate interface for creating and monitoring
migrations using DMS. Because this feature is currently in preview and the process is like
using the DMS service natively, it isn’t covered in detail in this book.
Note If you want to learn to use Azure Data Studio with the Azure SQL Migration
extension, please see https://learn.microsoft.com/azure/dms/
tutorial-sql-server-azure-sql-database-offline-ads.
443
Chapter 18 Migrating to Hyperscale
Note Premium Azure Storage accounts are not supported by the import process.
There are several methods and tools you can use to import the BACPAC into the
Hyperscale database, including the following:
• Azure PowerShell
• Azure CLI
For brevity, we’ll show the process of using the Azure Portal only.
1. Select the Overview blade in a SQL Server (logical server)
resource.
444
Chapter 18 Migrating to Hyperscale
6. Click OK.
445
Chapter 18 Migrating to Hyperscale
2. Once the target database is in sync with the source database, stop
any workloads from using the source database.
The benefit of this approach is that the amount of time that the database is offline is
minimized, so this could be considered an online migration. However, there are several
considerations to be aware of when planning this approach.
• You must manage and monitor the replication from SQL Server
rather than Azure SQL Database.
Summary
In this chapter, we covered some of the many different techniques available to migrate
existing SQL databases into the Azure SQL Database Hyperscale tier. These techniques
also apply to migrating to any tier in Azure SQL Database.
We also took a brief look at some of the tools available to analyze and migrate your
SQL Database instances, including the following:
In the next chapter, we will take a look at the options for reverse migrating away from
Hyperscale should you find it necessary.
447
CHAPTER 19
• Once you migrate your existing database to Hyperscale, you will have
a 45-day window to reverse migrate back to the General Purpose
service tier.
449
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_19
Chapter 19 Reverse Migrating Away from Hyperscale
Tip Bear in mind that migration to Hyperscale and reverse migration back to
General Purpose will depend mostly on database size.
Once you have database reverse migrated back to the General Purpose service tier,
you can then convert it to an alternative service tier, such as Business Critical (or even
back to Hyperscale).
• Azure Portal
• Azure CLI
450
Chapter 19 Reverse Migrating Away from Hyperscale
Figure 19-1. Azure Portal “Service and compute tier” pane of Azure SQL
Database
2. Under the “Service and compute tier” pane, choose the General
Purpose service tier from the drop-down menu.
You will notice that only General Purpose is available for your
reverse migration targeted service tier, as shown in Figure 19-2.
3. Once you have selected the General Purpose service tier, you
can confirm the reverse migration, and the process will begin.
The time it takes may vary, depending mostly on database size.
Figure 19-3 shows the scaling in progress pane after reverse
migration was triggered.
451
Chapter 19 Reverse Migrating Away from Hyperscale
2. Scroll down to the bottom of the Overview blade and click the
Notifications tab. Figure 19-4 shows the database info message on
the Notifications tab.
3. You can review the process of the reverse migration by clicking the
operation. Figure 19-5 shows the progress against our Hyperscale
deployment.
452
Chapter 19 Reverse Migrating Away from Hyperscale
You can cancel this scaling operation if it is in progress by clicking the “Cancel this
operation” button. You will be asked to click to confirm the cancelation. Figure 19-6
shows canceling the scaling database operation.
453
Chapter 19 Reverse Migrating Away from Hyperscale
Using any of these mentioned tools, you can run the following T-SQL statement to
reverse migrate your Hyperscale database back to the General Purpose tier:
Figure 19-7 shows the ongoing scaling database progress including the completion
percentage.
454
Chapter 19 Reverse Migrating Away from Hyperscale
Tip All the Azure CLI commands are easily available at the Microsoft Learn Portal:
https://learn.microsoft.com/cli/azure/reference-index.
4. Once you are on the right subscription, you can list all the
available Azure SQL Database instances hosted on your logical
SQL Server.
5. After finding your desired Hyperscale database, you can run this
command to perform the Reverse migration process:
455
Chapter 19 Reverse Migrating Away from Hyperscale
To cancel an in-progress operation, you will need the unique name of the operation
you want to cancel. You can get the operation name by executing the previous az sql db
op list Azure CLI command. Once you have the unique name of the operation, you can
cancel it using the following statement:
Tip Be aware that the cancel operation is not instantaneous, and it might take
some time. You can follow the progress using the az sql db op list command
and looking for the query state CancelInProgress.
456
Chapter 19 Reverse Migrating Away from Hyperscale
The solution in this case is to back up your Hyperscale database and restore it to
a new database with the desired service tier. Alternatively, you could use a different
migration methodology, some of which were documented in the previous chapter.
Summary
In this chapter, we showed the process of reverse migration from Hyperscale back to
the General Purpose service tier in case you decide that the Hyperscale database is
not the right option for your current production workload. We described the different
techniques that might use for reverse migration, including the following:
457
Chapter 19 Reverse Migrating Away from Hyperscale
• Azure Portal
• Azure CLI
• Transact SQL
We also showed some of the issues you might encounter during a reverse migration
process.
458
CHAPTER 20
Conclusion
Azure SQL Hyperscale is an exciting evolution of relational database management
system architecture. The increasing pace of innovation and change occurring in the
public cloud has enabled new, more scalable, decoupled, and distributed design
patterns. Access to on-demand computing and scalable object storage has led to a shift
toward scale-out architectures. With these fundamental shifts in available technologies
and increasing demands for scale, it is the right time for more traditional relational
database technologies to leverage these technologies to make the next leap forward.
Azure SQL Hyperscale is the most significant jump forward in how SQL Server workloads
are implemented since the first implementation of Azure SQL PaaS.
Azure SQL Hyperscale is likely to be the first iteration of this exciting technology. As
this technology evolves, supported by the innovations provided by the underlying Azure
cloud services, such as storage snapshots, we will see many other enhancements. These
innovations will help this approach to become more widely used within the Azure SQL
Database family of products. Improvements in speed to scale-outs and scale-ins could
lead to greater leverage of on-demand compute and make Hyperscale an attractive
option in a greater range of scenarios.
To recap, these are some of the key differences that the shift to Hyperscale
architecture enable:
459
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9_20
Chapter 20 Conclusion
These features and many more make Hyperscale a great fit for both simple and
complex data scenarios. Understanding why this architecture is so different will help you
ensure you’re making the most of what it can do. Maximizing the benefit Hyperscale can
provide requires knowing its strengths and designing your workloads to make the best
use of them. Designing your workloads to make use of scale-out will net you cost savings
and increases in scalability and resilience.
The goal of this book has been to provide you with a deeper insight into Hyperscale
as well as all the adjoining technologies. With this knowledge, you’ll be able to design,
deploy, and operate large-scale Hyperscale environments and continue to leverage the
dramatic innovations that this enables.
Thank you for taking the journey to learning about this game-changing SQL Server
architecture in Azure. We hope the knowledge in these pages helps you maximize your
investment in the technology, enabling it to meet your requirements and go far beyond.
460
Index
A az sql db create command, 255, 256
az sql db replica create command, 261
Accelerated database recovery (ADR),
az sql server audit-policy update
48, 49, 69
command., 258
Access management, 382
Azure Active Directory (AAD)
Azure Active Directory (AAD)
authentication, 381, 382, 387
authentication, 387
Azure availability zone (AZ), 14, 19,
logical server authentication, 388
127, 365
permissions in the database
Azure Bastion
engine, 390
AzureBastionSubnet, 161
role-based access control (RBAC), 389
Azure Portal, 163
row-level security (RLS), 390
configuration, 166
SQL authentication, 387
connection, 167, 168
Active Directory (AD), 80, 100, 108, 110, 136
creation, 165
Add-AzKeyVaultKey command, 224
diagram, 162
Alert rules, 345–350, 354
management VM, 163, 167, 168
Always Encrypted feature, 394
subnets, 170
Audit logs, 233
Azure Bicep, 268, 400
destination types, 207
deployment, 268, 269
log analytics workspace, 207–209
Bash script, 270, 271
production databases, 207
Hyperscale, 272–284
Authentication
PowerShell script, 269, 270
Azure AD, 110–112
Azure CLI command, 400, 450, 454–456
benefits, 111
audit logs, 258, 263
definition, 109
create helper variables, 247, 248
logical servers, 109
diagnostic logs, 260, 263
MFA, 112
Hyperscale database, 255–257
Authorization, 109
Key Vault Crypto Officer, 264
Automation Runbook, 346
Log Analytics workspace, 257, 258
Autoscaling, 360
logical server, 253
az ad sp list command, 251
logical server, failover region, 260
az deployment sub create command, 283
logical server, primary region, 252
az role assignment create command, 251
461
© Zoran Barać and Daniel Scott-Raynsford 2023
Z. Barać and D. Scott-Raynsford, Azure SQL Hyperscale Revealed,
https://doi.org/10.1007/978-1-4842-9225-9
INDEX
Azure CLI command (cont.) Azure Resource Manager (ARM), 216, 268
replica, 261–263 Azure resources, 126, 129, 131
TDE protector key, 249–252 Azure SQL
user-assigned managed identity, concepts, 35, 36
248, 249 DB vs. MI, 6
virtual network, 253–255 deployment types, 6
Azure cloud services, 459 hosting models, 7
Azure Data Factory, 94 Hyperscale, 5
Azure Data Studio (ADS), 162, 420, 421, PaaS (see Platform-as-a-service (PaaS))
438, 443, 447 purchasing models, 11, 12
Azure DMS, 420, 432, See also Database service tier, 11, 12
Migration Service (DMS) workloads, 5, 6
Azure DMS resource, 438, 439 Azure SQL Analytics, 334, 355
Azure Function, 346 Azure SQL database audit, 390, 391
Azure Hybrid Benefit (AHB), Azure SQL database notification
399, 400, 417 massage, 452
Azure Key Vaults, 130, 132, 172–174, 178, Azure SQL database security
180, 186 access management, 382, 387, See also
Azure Log Analytics workspace, 355 Access management
AzureMetrics table, 345 auditing and threat detection, 382, 390
Azure paired region, 187 Azure SQL database audit, 390, 391
Azure Portal, 126, 140, 141, 355, 423, 434, Microsoft Defender for Cloud,
436, 438, 444, 446 391, 392
Azure PowerShell, 400, 450 Azure Portal security pane, 382
audit logs, 233–235, 238 database-level security features,
create helper variables, 220, 221 383, 384
database, 231–233 information protection, 382, 392,
diagnostic logs, 233–235, 238 See Information protection
Key Vault, 238, 239 network security (see Network
logical server, 226, 227 security)
replica database, 236–238 security features, 381, 382
TDE protector key, 223–226 security layers, 382
user-assigned managed identity, Azure SQL deployments, 286, 381, 414
222, 223 Azure SQL Insights, 354
virtual network, 228–231 Azure Standard Storage, 15, 54, 59, 60, 62,
VNet, 235, 236 67–70, 73
Azure Pricing Calculator, 399, 402 Azure virtual machine, 354
Azure Private Link, 102, 140, 191, 193 Azure virtual networks, 130, 140
462
INDEX
B D
Backup retention Database administrators (DBAs), 159–161
policy, 61, 362–364 Database (DB), 3, 5
Backup storage redundancy, 127, 145, 365, Data Migration Assistant (DMA), 420,
366, 371, 379, 414 421, 447
BACPAC file, 444, 445 acceleration, 431
Bring your own key migrating with DMS, 426–431
(BYOK), 171–186, 393 requirements, 425
Buffer Pool Extension (BPE), 41, 44, 358 Windows desktop tool, 425
Business continuity, 410, 413–415 Data Migration Service (DMS), 420,
Business continuity/disaster recovery 426, 432
(BCDR), 380 Azure PowerShell method, 438
Business Critical service tier, 14, 18, 19, benefits, 432
308, 320, 375, 376, 456 migration project, 438
migrations, 432, 433
migration summary screen, 431
C networking connectivity, 433, 434
Clients, 94, 95, 107, 108, 386 performance, 438–442
Cloud computing, 37 resource creation, 436, 437
CloudDB, 5 resource in the Azure Portal, 436
Command-Line Interface (CLI), 211 resource providers, registration, 434, 435
Connection policy, 103, 386–387 tiers, 433
Cost of Hyperscale, 410 Data sync and cutover method, 420, 421,
Crypto Service Encryption User, 173, 180, 424, 446
196, 225, 251, 273 Data transaction units (DTUs), 11,
Customer-managed, TDE 12, 15, 36
enabling, 184–186 Diagnostic logs, 233
key generation, 178, 180 destination types, 207
Key Vault, 172, 173 log analytics, 209, 211
Key Vault Crypto Officer, user, 175–177 monitoring, 206
system-assigned Disaster recovery, 21, 57, 77, 81, 127,
managed identity, 173 187–201, 361–380
tasks, 173, 174 Distributed denial-of-service
user-assigned managed identity, 173 (DDoS), 99, 100
access, 180, 181 Domain-specific language (DSL), 215, 268
creation, 174, 175 Dynamic data masking, 383, 394–396
logical server, 182, 183 Dynamic managed views (DMVs), 353, 354
Customers, 4
463
INDEX
E Get-AzDiagnosticSettingCategory
command, 234
Email, 205, 345
GitHub repository, 125, 134, 157, 270
Encryption keys, 171, 172, 175
Event Hub, 122, 207, 346
Event streaming architectures, 4 H
Extract, transform, load (ETL), 94
HammerDB tool
Autopilot, 299, 300
F driver script, 293, 294
checkpoint, 296
Failover Cluster Instance (FCI), 15, 39
client login, 297
Firewall and virtual
exit on error, 296
network rules, 385
Keying and Thinking Time, 296
Fully qualified domain name (FQDN),
mode, 297
94–96, 101
ramp-up time, 296
scaling feature, 297
G test duration, 296
General Purpose Standard-series time, 295
(Gen5), 375 time profiling, 297
Geo-redundant backup storage total transactions per user, 295
(RA-GRS), 91, 365 virtual user, 297
Geo-replication, 363, 377–379 warehouse, 296
Azure Portal, 198 XML, 297
backup storage, 199 schema build, 288–293
configuration tasks, 188, 189, 198 TPROC-C OLTP workload, 287
customer-managed key TDE TPROC-C workload, 300, 301
configuration, 197 version, 287
failover region, 196–198 virtual users, 297, 298
Key Vault, 196 parameters, 298, 299
permissions, 196 Hardware security module (HSM), 116,
primary, 196, 198 171, 172
database, 198 Hybrid transactional and analytical
failover replica, 200 processing (HTAP), 87
logical server (see Logical server) Hyperscale, 460
replicas blade, 199, 200 ADR, 48, 49
Geo-restore, 368, 369, 373, 374, 377 architecture
Geo-zone-redundant backup storage advantages, 51, 58
(RA-GZRS), 92, 145, 365 diagram, 49, 50
464
INDEX
465
INDEX
466
INDEX
467
INDEX
468
INDEX
469
INDEX
470
INDEX
Hyperscale service tier, 308, 309 SQL server, 3, 5, 6, 9, 18, 20, 34, 41, 48, 49,
metrics graph, 311 78, 80, 103, 140, 162, 252, 276, 288,
performance results, 311 290, 301, 307, 314, 343, 363, 375,
progress, 310 387, 425, 439
Security, 78, 108 SQL Server Management Studio (SSMS),
areas, 108, 109 98, 111, 161, 162, 168, 170
authentication, 109–112 Standard availability model, 15, 16, 39
cost/complexity, 108 Storage snapshots, 459
logical server identities, 114, 115
Microsoft Defender, SQL
advanced threat protection, 112 T
enabling, 113 TDE protector, 172, 173, 176, 178, 180, 185,
pricing details, 113 196, 219, 222, 224
storage account, 114 Total cost of ownership (TCO), 6, 399,
vulnerability assessments, 112 405, 416
and network connectivity, 108 TPORC-C workload
transparent data encryption, 116–119 Business Critical service tier, 318–320
Service level objective (SLO), 36, 42, 127 General Purpose service tier, 315, 317
Short-term retention policy (STR), 92 Hyperscale service tier, 321–327, 329–334
SMS message, 345, 346, 348, 349 parameters, 312, 313
Software-as-a-service (SaaS), 3, 4, 9, performance results, 335
94, 95, 131 SQL, 314
Solid-state disk (SSD), 18, 39–41, 52, 59, virtual user, 314
61, 62, 73, 74 TPROC-C OLTP workload, 287, 336
SQL administrators, 110 Traditional Azure SQL Database, 47,
creation, 136–139 375, 409
security group, 136 Transaction Processing Performance
SQL Analytics Council (TPC), 286
Azure Portal, 355 Transactions, 3
dashboard view, 356 Transactions per minute (TPM), 296,
solution summary, 356 316, 325
SQL Hyperscale environment Transact SQL (T-SQL), 37, 55, 56, 424, 446,
Azure CLI 450, 453, 454
deploy, 243–245 Transparent data encryption (TDE), 127,
environments, 242 130, 150, 172
install, 242, 243 customer-managed (see Customer-
Bash script, 245, 246 managed, TDE)
SQL Insights, 354, 360 Hyperscale, 172
471
INDEX
472