AZ 204 Master Cheat Sheet
AZ 204 Master Cheat Sheet
References
Microsoft Certifications - AZ-204
Topics:
6. Develop, test, and publish Azure Functions by using Azure Functions Core
Tools
4. Enable reliable messaging for Big Data applications using Azure Event Hubs
pg. 1
SKILLCERTPRO
4. Build and run a web application with the MEAN stack on an Azure Linux virtual
machine
Business processes modeled in software are often called workflows. Azure includes
four different technologies that you can use to build and implement workflows that
integrate multiple systems
pg. 2
SKILLCERTPRO
Logic Apps
Microsoft Power Automate
WebJobs
Azure Functions
Accept Inputs
Run Actions
Include Condition
Produce Output
Triggered on a schedule or other external events
Design-First Approach
It includes user interface in which you can design the workflow and includes the
following technologies:
Logic Apps
A service that you can use to automate, orchestrate and integrate disparate
components of a distributed application. You can use Logic Apps Designer to
define the workflow. Alternatively, you may prefer to code the workflow in
JSON notations using the code-view.
A connector is a Logic Apps component that provides an interface to an
external service. Logic Apps provides hundreds of pre-built connectors that
you can use to create your apps. If you have an unusual or unique system that
you want to call from a Logic Apps, you can create your own connector if your
system exposes a REST API.
pg. 3
SKILLCERTPRO
Microsoft Power
Logic Apps
Automate
Office workers
Developers and IT
Intended users and business
pros
analysts
Code-First Approach
When you need more control over the performance of your workflow or need to
write custom code as part of your business process, the following technologies
would help:
Azure WebJobs
WebJobs are a part of the Azure App Service that you can use to run a
program or script automatically. The two kinds are:
o Continous
o Triggered
pg. 4
SKILLCERTPRO
You can create a Webjob by using Shell Scripts (Windows, Powershell, Bash) or
by writing a program in PHP, Python, Node.js, or Java. You can also program a
WebJob by using the .NET Framework or the .NET Core Framework and a .NET
language such as C# or VB.NET.
Along with C# .NET you can use the WebJobs SDK which includes a range of
classes, such as JobHostConfiguration and HostBuilder, which reduce the
amount of code required to interact with the Azure App Service.
Azure Functions An Azure Function is a simple way for you to run small
pieces of code in the cloud, without having to worry about the infrastructure
required to host that code. You can write the Function in C#, Java, JavaScript,
PowerShell, Python, or any of the languages that are listed in the Supported
languages in Azure Functions article. In addition, with the consumption plan
option, you only pay for the time when the code runs. Azure automatically
scales your function in response to the demand from users.
o HTTPTrigger
o TimerTrigger
o BlobTrigger
o CosmosDBTrigger
Azure Functions can integrate with many different services both within Azure
and from third parties. These services can trigger your function, or send data
input to your function, or receive data output from your function.
In most cases, the simple administration and more flexible coding model provided by
Azure Functions may lead you to choose them in preference to WebJobs. However,
you may choose WebJobs for the following reasons:
You want the code to be a part of an existing App Service application and to
be managed as part of that application, for example in the same Azure
DevOps environment.
You need close control over the object that listens for events that trigger the
code. This object in question is the JobHost class, and you have more
flexibility to modify its behavior in WebJobs.
pg. 5
SKILLCERTPRO
I you choose a code-first approach, you can develop a complex business logic and
wrap the solution in a custom connector which can be integrated with Logic Apps or
Power Automate. As a developer, you get more flexibility by this approach.
pg. 6
SKILLCERTPRO
Stateless logic - Stateless functions are great candidates for serverless compute;
function instances are created and destroyed on demand. If state is required, it can
be stored in an associated storage service.
Event driven - Functions are event driven. This means they run only in response to
an event (called a "trigger"), such as receiving an HTTP request, or a message being
added to a queue. You configure a trigger as part of the function definition. This
pg. 7
SKILLCERTPRO
approach simplifies your code by allowing you to declare where the data comes from
(trigger/input binding) and where it goes (output binding).
While scaling, only one function app instance can be created every 10 seconds, for up
to 200 total instances. Keep in mind, each instance can service multiple concurrent
executions, so there is no set limit on how much traffic a single instance can handle.
Different types of triggers have different scaling requirements, so research your choice
of trigger and investigate its limits.
Consumption service plan - This is the plan that you choose when using the Azure
serverless application platform. The Consumption service plan provides automatic
scaling and bills you when your functions are running. The Consumption plan comes
with a configurable timeout period for the execution of a function. By default, it is 5
minutes, but may be configured to have a timeout as long as 10 minutes.
Azure App Service plan - This plan allows you to avoid timeout periods by having
your function run continuously on a VM that you define. When using an App Service
plan, you are responsible for managing the app resources the function runs on, so
pg. 8
SKILLCERTPRO
this is technically not a serverless plan. However, it may be a better choice if your
functions are used continuously or if your functions require more processing power
or execution time than the Consumption plan can provide.
When you create a function app, it must be linked to a storage account. You can
select an existing account or create a new one. The function app uses this storage
account for internal operations such as logging function executions and managing
execution triggers. On the Consumption service plan, this is also where the function
code and configuration file are stored.
Triggers
The type of event that starts the function is called a trigger. You must configure a
function with exactly one trigger. Azure supports triggers for the following services:
Azure Cosmos
Start a function when inserts and updates are detected.
DB
Event Grid Start a function when an event is received from Event Grid.
Bindings
Bindings are a declarative way to connect data and services to your function.
pg. 9
SKILLCERTPRO
Bindings know how to talk to different services, which means you don't have to write
code in your function to connect to data sources and manage connections. The
platform takes care of that complexity for you as part of the binding code. Each
binding has a direction - your code reads data from input bindings and writes data
to output bindings. Each function can have zero or more bindings to manage the
input and output data processed by the function.
Monitoring dashboard
The Azure portal provides a monitoring dashboard available if you turn on the
Application Insights integration. This monitor dashboard provides a quick way to
view the log of function executions populated by Application Insights.
What is a CRON expression? A CRON expression is a string that consists of six fields
that represent a set of times.
The order of the six fields in Azure is: {second} {minute} {hour} {day} {month} {day of
the week}.
For example, a CRON expression to create a trigger that executes every five minutes
looks like: 0 */5 * * * *
Special
Meaning Example
Character
Selects every An asterisk "*" in the day of the week field means
**
value in a field every day.
pg. 10
SKILLCERTPRO
Special
Meaning Example
Character
Function
Anonymous
Admin
The Function and Admin levels are "key" based. There are two types of keys:
function and host. Function keys are specific to a function. Host keys apply to all
functions inside the function app. If your Authorization level is set to Function, you
can use either a function or a host key. If your Authorization level is set to Admin,
you must supply a host key.
The Anonymous level means that there's no authentication required.
What is Azure Blob storage? - Azure Blob storage is an object storage solution
that's designed to store large amounts of unstructured data.
For example, Azure Blob storage is great at doing things like:
Storing files
Serving files
Streaming video and audio
Logging data
pg. 11
SKILLCERTPRO
There are three types of blobs: block blobs, append blobs, and page blobs. Block
blobs are the most common type. They allow you to store text or binary data
efficiently. Append blobs are like block blobs, but they're designed more for append
operations like creating a log file that's being constantly updated. Finally, page blobs
are made up of pages and are designed for frequent random read and write
operations.
Types of bindings
Triggers are special types of input bindings that cause a function to execute.
Blob Storage
Azure Service Bus Queues
Azure Cosmos DB
Azure Event Hubs
External Files
External Tables
HTTP endpoints
These types are just a sample. There are more, plus functions have an extensibility
model to add more bindings.
Binding properties
Name - Defines the function parameter through which you access the data.
For example, in a queue input binding, this is the name of the function
parameter that receives the queue message content.
pg. 12
SKILLCERTPRO
Type - Identifies the type of binding, i.e., the type of data or service we want
to interact with.
Direction - Indicates the direction data is flowing, i.e., is it an input or output
binding?
Connection - Provides the name of an app setting key that contains the
connection string. Bindings use connection strings stored in app settings to
keep secrets out of the function code. It is only used for bindings which
require connection string.
Create a binding
Bindings are defined in JSON. A binding is configured in your function's
configuration file, which is named function.json and lives in the same folder as your
function code. Following is a sample of binding definition.
...
{
"name": "headshotBlob",
"type": "blob",
"path": "thumbnail-images/{filename}",
"connection": "HeadshotStorageConnection",
"direction": "in"
},
...
App settings
Trigger file name
Trigger metadata
JSON payloads
New GUID
Current date and time
Most expressions are identified by wrapping them in curly braces. However, app
setting binding expressions are wrapped in percent signs rather than curly braces.
For example if the blob output binding path is %Environment%/newblob.txt and the
Environment app setting value is Development, a blob will be created in the
Development container.
pg. 13
SKILLCERTPRO
They enable you to write event driven code. A durable function can wait
asynchronously for one or more external events, and then perform a series of
tasks in response to these events.
You can chain functions together. You can implement common patterns such
as fan-out/fan-in, which uses one function to invoke others in parallel, and
then accumulate the results.
You can orchestrate and coordinate functions, and specify the order in which
functions should execute.
The state is managed for you. You don't have to write your own code to save
state information for a long-running function.
You can define the workflows in code. You don't need to write a JSON
description or use a workflow design tool.
Functions can be called both synchronously and asynchronously. Output from
the called functions is saved locally in variables and used in subsequent
function calls.
Azure checkpoints the progress of a function automatically when the function
awaits. Azure may choose to dehydrate the function and save its state while
pg. 14
SKILLCERTPRO
the function waits, to preserve resources and reduce costs. When the function
starts running again, Azure will rehydrate it and restore its state.
Function types
You can use three durable function types: client, orchestrator, and activity.
Client functions are the entry point for creating an instance of a Durable
Functions orchestration. They can run in response to an event from many
sources, such as a new HTTP request arriving, a message being posted to a
message queue, an event arriving in an event stream. You can write them in
any of the supported languages.
Orchestrator functions describe how actions are executed, and the order in
which they are run. You write the orchestration logic in code (C# or
JavaScript).
Activity functions are the basic units of work in a durable function
orchestration. An activity function contains the actual work performed by the
tasks being orchestrated.
Application patterns
You can use Durable Functions to implement many common workflow patterns.
These patterns include:
pg. 15
SKILLCERTPRO
const df = require("durable-functions");
const moment = require("moment");
module.exports = df.orchestrator(function*(context) {
for (let i = 0; i < 10; i++) {
const dayOfMonth = context.df.currentUtcDateTime.getDate();
const deadline = moment.utc(context.df.currentUtcDateTime).add(1, 'd');
yield context.df.createTimer(deadline.toDate());
yield context.df.callActivity("SendReminder");
}
});
Always use currentUtcDateTime to obtain the current date and time, instead
of Date.now or Date.UTC.
const df = require("durable-functions");
const moment = require("moment");
module.exports = df.orchestrator(function*(context) {
const deadline = moment.utc(context.df.currentUtcDateTime).add(30, "s");
pg. 16
SKILLCERTPRO
{
// timeout case
return false;
}
});
6. Develop, test, and publish Azure Functions by using Azure Functions Core
Tools
The parameters passed to the Run method provide the context for the trigger. In the
case of an HTTP trigger, the function receives an HttpRequest object. This object
contains the header and body of the request. You can access the data in the request
using the same techniques available in any HTTP application. The attributes applied
to this attribute specify the authorization requirements (Anonymous in this case), and
the HTTP operations to which the Azure function responds (GET and POST).
pg. 17
SKILLCERTPRO
}
}
The function returns a value containing any output data and results, wrapped in an
IActionResult object. The value is returned in the body of the HTTP response for the
request.
Different types of trigger receive different input parameters and return types. The
next example shows the code generated for a Blob trigger. In this example, the
contents of the blob is made accessible through a Stream object, and the name of
the blob is also provided. No data is returned by the trigger; its purpose is to read
and process the data in the named blob:
In all cases, an Azure Function is passed an ILogger parameter. The function can use
this parameter to write log messages, which the function app will write to storage for
later analysis.
An Azure Function also contains metadata that specify the type of the trigger and
any other specific information and security requirements. You can modify this
metadata using the HttpTrigger, BlobTrigger, or other trigger attributes, as shown in
the examples. The FunctionName attribute that precedes the function is an identifier
for the function used by the function app. This name doesn't have to be the same as
the name of the function, but it's good practice to keep them synchronized to avoid
confusion.
Exercise - Create and test a simple Azure Function locally with Visual Studio
pg. 18
SKILLCERTPRO
Deploy from Visual Studio - Azure Functions tools for Visual Studio enable
you to deploy an Azure Function directly from Visual Studio. The Azure
Functions template provides a Publish wizard. Using this wizard, you connect
to your Azure account, and either specify an existing Azure Function App, or
create a new one. The functions in your project are rebuilt and then deployed
to the Azure Function App.
Continuous deployment - Azure Functions makes it easy to deploy your
function app using App Service continuous integration. Azure Functions
integrates with BitBucket, Dropbox, GitHub, and Azure DevOps. This enables a
workflow where function code updates made by using one of these integrated
services triggers deployment to Azure.
Zip deployment - Azure Function can be deployed from a zip file using the
push deployment technique. You can do this with the Azure CLI, or by using
the REST interface.
Webhooks are user-defined HTTP callbacks. They offer a lightweight mechanism for
apps to be notified by another service when something of interest happens via an
HTTP endpoint. You can use a webhook to trigger an Azure function, and then
analyze the message, to determine what happened and how to respond.
pg. 19
SKILLCERTPRO
network traffic and load on the server. SignalR allows you to easily add this type of
architecture to your application.
SignalR is an abstraction for a series of technologies that allows your app to enjoy
two-way communication between the client and server. SignalR handles connection
management automatically, and lets you broadcast messages to all connected clients
simultaneously, like a chat room. You can also send messages to specific clients. The
connection between the client and server is persistent, unlike a classic HTTP
connection, which is re-established for each communication.
For clients that support HTML 5, the WebSockets API transport is used by default. If
the client doesn't support WebSockets, then SignalR falls back to Server Sent Events
(also known as EventSource). For older clients, Ajax long polling or Forever Frame (IE
only) is used to mimic a two-way connection.
The abstraction layer offered by SignalR provides two benefits to your application.
The first advantage is future-proofing your app. As the web evolves and APIs
superior to WebSockets become available, your application doesn't need to change.
You could update to a version of SignalR that supports any new APIs and your
application code won't need an overhaul.
The second benefit is that SignalR allows your application to gracefully degrade
depending on supported technologies of the client. If it doesn't support WebSockets,
then Server Sent Events are used. If the client can't handle Server Sent Events, then it
uses Ajax long polling, and so on.
When you copy files to a storage container named $web, those files are available to
web browsers via a secure server using the
https://<ACCOUNT_NAME>.<ZONE_NAME>.web.core.windows.net/<FILE_NAME>
URI scheme.
pg. 20
SKILLCERTPRO
What is a Message?
In the terminology of distributed applications, messages have the following
characteristics:
What is an Event?
Events are lighter weight than messages, and are most often used for broadcast
communications. The components sending the event are known as publishers, and
receivers are known as subscribers.
With events, receiving components will generally decide in which communications
they are interested, and will "subscribe" to those events. The subscription is managed
by an intermediary, like Azure Event Grid or Azure Event Hubs. When publishers send
an event, the intermediary will route that event to interested subscribers. This pattern
is known as a "publish-subscribe architecture." It's not the only way to deal with
events, but it is the most common.
pg. 21
SKILLCERTPRO
For each communication, consider the following question: Does the sending
component expect the communication to be processed in a particular way by
the destination component?
If the answer is yes, choose to use a message. If the answer is no, you may be able to
use events.
Azure Queue Storage - Queue storage is a service that uses Azure Storage to store
large numbers of messages that can be securely accessed from anywhere in the
world using a simple REST-based interface. Queues can contain millions of messages,
limited only by the capacity of the storage account that owns it.
Azure Service Bus Queues - Service Bus is a message broker system intended for
enterprise applications. These apps often utilize multiple communication protocols,
have different data contracts, higher security requirements, and can include both
cloud and on-premises services. Service Bus is built on top of a dedicated messaging
infrastructure designed for exactly these scenarios.
Azure Service Bus Topics - Azure Service Bus topics are like queues, but can have
multiple subscribers. When a message is sent to a topic instead of a queue multiple
components can be triggered to do their work. Internally, topics use queues. When
you post to a topic, the message is copied and dropped into the queue for each
subscription. The queue means that the message copy will stay around to be
processed by each subscription branch even if the component processing that
subscription is too busy to keep up.
Benefits of Queue
Queue infrastructures can support many advanced features that make them very
useful in the following ways:
Increased reliability
Queues are used by distributed applications as a temporary storage location
for messages pending delivery to a destination component. The source
component can add a message to the queue and destination components can
pg. 22
SKILLCERTPRO
retrieve the message at the front of the queue for processing. Queues increase
the reliability of the message exchange because, at times of high demand,
messages can simply wait until a destination component is ready to process
them.
Transaction support
Some closely related groups of messages may cause problems when delivery
fails for one message in the group.
For example, consider an e-commerce application. When the user clicks the
Buy button, a series of messages might be generated and sent off to various
processing destinations:
pg. 23
SKILLCERTPRO
In this case, we want to make sure all messages get processed, or none of them are
processed. We won't be in business long if the credit card message is not delivered,
and all our orders are fulfilled without payment! You can avoid these kinds of
problems by grouping the two messages into a transaction. Message transactions
succeed or fail as a single unit - just like in the database world.
You need an audit trail of all messages that pass through the queue.
You expect the queue to exceed 80 GB in size.
You need to handle messages less than 64 KB.
You want to track progress for processing a message inside of the queue.
pg. 24
SKILLCERTPRO
Functions or Webhooks. Event Grid was created to make it easier to build event-
based and serverless applications on Azure.
Event Grid supports most Azure services as a publisher or subscriber and can be used
with third-party services. It provides a dynamically scalable, low-cost, messaging
system that allows publishers to notify subscribers about a status change. The
following illustration shows Azure Event Grid receiving messages from multiple
sources and distributing them to event handlers based on subscription.
There are several concepts in Azure Event Grid that connect a source to a subscriber:
The following illustration shows an Azure Event Grid positioned between multiple
event sources and multiple event handlers. The event sources send events to the
Event Grid and the Event Grid forwards relevant events to the subscribers. Event Grid
use topics to decide which events to send to which handlers. Events sources tag each
event with one or more topics, and event handlers subscribe to the topics they are
interested in.
What is an event?
Events are the data messages passing through Event Grid that describe what has
taken place. Each event is self-contained, can be up to 64 KB, and contains several
pieces of information based on a schema defined by Event Grid:
[
{
"topic": string,
"subject": string,
"id": string,
"eventType": string,
"eventTime": string,
"data":{
object-unique-to-each-publisher
},
"dataVersion": string,
"metadataVersion": string
}
]
pg. 25
SKILLCERTPRO
Field Description
One of the registered event types for this event source. This
eventType is a value you can create filters against, e.g.
CustomerCreated, BlobDeleted, HttpRequestReceived, etc.
Types of event sources Events can be generated by the following Azure resource
types:
pg. 26
SKILLCERTPRO
System topics are built-in topics provided by Azure services. You don't see
system topics in your Azure subscription because the publisher owns the
topics, but you can subscribe to them. To subscribe, you provide information
about the resource you want to receive events from. As long as you have
access to the resource, you can subscribe to its events.
Custom topics are application and third-party topics. When you create or are
assigned access to a custom topic, you see that custom topic in your
subscription.
pg. 27
SKILLCERTPRO
Types of event handlers The following object types in Azure can receive and handle
events from Event Grid:
Azure Functions: Custom code that runs in Azure, without the need for
explicit configuration of a host virtual server or container. Use an Azure
function as an event handler when you want to code a custom response to the
event.
Webhooks: A webhook is a web API that implements a push architecture.
Azure Logic Apps: An Azure logic app hosts a business process as a workflow.
Microsoft Flow: Flow also hosts workflows, but it is easier for non-technical
staff to use.
Should you use Event Grid? Use Event Grid when you need these features:
Event Grid is a simple but versatile event distribution system. Use it to deliver discrete
events to subscribers, which will receive those events reliably and quickly. We have
one more messaging model to examine - what if we want to deliver a large stream of
events? In this scenario, Event Grid isn't a great solution because it's designed for
one-event-at-a-time delivery. Instead, we need to turn to another Azure service:
Event Hubs.
pg. 28
SKILLCERTPRO
Message time to live - Message time to live determines how long a message
will stay in the queue before it expires and is removed or dead lettered. When
sending messages it is possible to specify a different time to live for only that
message. This default will be used for all messages in the queue which do not
specify a time to live for themselves.
Locked duration - Sets the amount of time that a message is locked for other
receivers. After its lock expires, a message pulled by one receiver becomes
available to be pulled by other receivers. Defaults to 30 seconds, with a
maximum of 5 minutes.
Enable duplicate detection - Enabling duplicate detection configures your
queue to keep a history of all messages sent to the queue for a configurable
amount of time. During that interval, your queue will not accept any duplicate
messages. Enabling this property guarantees exactly-once delivery over a
user-defined span of time.
Enable dead lettering on message expiration - Dead lettering messages
involves holding messages that cannot be successfully delivered to any
receiver to a separate queue after they have expired. Messages do not expire
in the dead letter queue, and it supports peek-lock delivery and all
transactional operations.
Enable sessions - Service bus sessions allow ordered handling of unbounded
sequences of related messages. With sessions enabled a queue can guarantee
first-in-first-out delivery of messages. Enable partitioning - Partitions a
queue across multiple message brokers and message stores. Disconnects the
overall throughput of a partitioned entity from any single message broker or
messaging store. This property is not modifiable after a queue has been
created.
pg. 29
SKILLCERTPRO
Boolean Filters - The TrueFilter ensures that all messages sent to the topic are
delivered to the current subscription. The FalseFilter ensures that none of the
messages are delivered to the current subscription. (This effectively blocks or
switches off the subscription.)
SQL Filters A SQL filter specifies a condition by using the same syntax as
a WHERE clause in a SQL query. Only messages that return True when
evaluated against this subscription will be delivered to the subscribers.
Correlation Filters A correlation filter holds a set of conditions that are
matched against the properties of each message. If the property in the filter
and the property on the message have the same value, it is considered a
match.
Access authorization
Every request to a queue must be authorized and there are several options to choose
from. |Authorization Type|Description| |Azure Active Directory|You can use role-based
authentication and identify specific clients based on AAD credentials.| |Shared
Key|Sometimes referred to as an account key, this is an encrypted key signature
associated with the storage account. Every storage account has two of these keys
that can be passed with each request to authenticate access. Using this approach is
like using a root password - it provides full access to the storage account.| |Shared
access signature|A shared access signature (SAS) is a generated URI that grants
limited access to objects in your storage account to clients. You can restrict access to
specific resources, permissions, and scope to a data range to automatically turn off
access after a period of time.|
pg. 30
SKILLCERTPRO
Notice that get and delete are separate operations. This arrangement handles
potential failures in the receiver and implements a concept called at-least-once
delivery. After the receiver gets a message, that message remains in the queue but is
invisible for 30 seconds. If the receiver crashes or experiences a power failure during
processing, then it will never delete the message from the queue. After 30 seconds,
the message will reappear in the queue and another instance of the receiver can
process it to completion.
4. Enable reliable messaging for Big Data applications using Azure Event Hubs
Consumer groups
An Event Hub consumer group represents a specific view of an Event Hub data
stream. By using separate consumer groups, multiple subscriber applications can
process an event stream independently, and without affecting other applications.
However, the use of many consumer groups isn't a requirement, and for many
applications, the single default consumer group is sufficient.
Pricing
There are three pricing tiers for Azure Event Hubs: Basic, Standard, and Dedicated.
The tiers differ in terms of supported connections, the number of available Consumer
groups, and throughput. When using Azure CLI to create an Event Hubs namespace,
if you don't specify a pricing tier, the default of Standard (20 Consumer groups, 1000
Brokered connections) is assigned.
pg. 31
SKILLCERTPRO
Event Hub name - Event Hub name that is unique within your subscription
and:
o Is between 1 and 50 characters long
o Contains only letters, numbers, periods, hyphens, and underscores
o Starts and ends with a letter or number
pg. 32
SKILLCERTPRO
Exercise - Evaluate the performance of the deployed Event Hub using the Azure
portal
Applications that publish messages to Azure Event Hub very frequently will get the best
performance using Advanced Message Queuing Protocol (AMQP) because it establishes
a persistent socket.
Convenience
Setting up SQL Server on a VM or on physical hardware requires you to know
about hardware and software requirements. You'll need to understand the
latest security best practices and manage operating system and SQL Server
patches on a routine basis. You also need to manage backup and data
retention issues yourself.
With Azure SQL Database, we manage the hardware, software updates, and
OS patches for you. All you specify is the name of your database and a few
options. You'll have a running SQL database in minutes.
Cost
Because we manage things for you, there are no systems for you to buy,
pg. 33
SKILLCERTPRO
Scale
With Azure SQL Database, you can adjust the performance and size of your
database on the fly when your needs change.
DTU
DTU stands for Database Transaction Unit, and is a combined measure of
compute, storage, and IO resources. Think of the DTU model as a simple,
preconfigured purchase option.
Because your logical server can hold more than one database, there's also the
idea of eDTUs, or elastic Database Transaction Units. This option enables you
to choose one price, but allow each database in the pool to consume fewer or
greater resources depending on current load.
vCore
vCores are Virtual cores, which give you greater control over the compute and
storage resources that you create and pay for.
While the DTU model provides fixed combinations of compute, storage, and
IO resources, the vCore model enables you to configure resources
independently. For example, with the vCore model you can increase storage
capacity but keep the existing amount of compute and IO throughput.
pg. 34
SKILLCERTPRO
can use the resources they need, within the limits you set, depending on current
load.
What is collation?
Collation refers to the rules that sort and compare data. Collation helps you define
sorting rules when case sensitivity, accent marks, and other language characteristics
are important.
Let's take a moment to consider what the default collation,
SQL_Latin1_General_CP1_CI_AS, means.
Pricing tiers
Azure Database for PostgreSQL provides you with the option to choose pricing tiers
based on parameters like compute power and storage.
Exercise - Create an Azure Database for PostgreSQL server via the Azure CLI
pg. 35
SKILLCERTPRO
databases to meet capacity spikes is more than 1.5 times the capacity required for
the elastic pool, then the pool will be cost effective.
At a minimum, it is recommended to add at least two S3 databases or fifteen S0
databases to a single pool for it to have potential cost savings.
Depending on the performance tier, you can add up to 100 or 500 databases to a
single pool.
Firewall rules
Azure SQL Database has a built-in firewall that is used to allow and deny network
access to both the database server itself, as well as individual databases. Initially, all
public access to your Azure SQL Database is blocked by the SQL Database firewall.
Firewall rules are configured at the server and/or database level, and will specifically
state which network resources are allowed to establish a connection to the database.
Depending on the level, the rules you can apply will be as follows:
pg. 36
SKILLCERTPRO
and Azure Container Service, as well as Azure VMs that have outbound
Internet access. This rule can be configured through the ON/OFF
option in the firewall pane in the portal, or by an IP rule that has 0.0.0.0
as the start and end IP addresses.
This rule is used when you have applications running on PaaS services
in Azure, such as Azure Logic Apps or Azure Functions, that need to
access your Azure SQL Database. Many of these services don't have a
static IP address, so this rule is needed to ensure they are able to
connect to the database.
o IP address rules - are rules that are based on specific public IP address
ranges. IP addresses connecting from an allowed public IP range will be
permitted to connect to the database.
pg. 37
SKILLCERTPRO
Credit card value, which only shows the last four digits of the number,
converting all other numbers to lower case x’s.
Email, which hides the domain name and all but the first character of the email
account name.
Number, which specifies a random number between a range of values. For
example, on the credit card expiry month and year, you could select random
months from 1 to 12 and set the year range from 2018 to 3000.
Custom string, which allows you to set the number of characters exposed from
the start of the data, the number of characters exposed from the end of the
data, and the characters to repeat for the remainder of the data.
When querying the columns, database administrators will still see the original values,
but non-administrators will see the masked values. You can allow other users to see
the non-masked versions by adding them to the SQL users excluded from masking
list.
pg. 38
SKILLCERTPRO
also required if you wish to use Azure threat detection on your Azure SQL database.
You can use SQL database auditing to:
Retain an audit trail of selected events. You can define categories of database
actions to be audited.
Report on database activity. You can use pre-configured reports and a
dashboard to get started quickly with activity and event reporting.
Analyze reports. You can find suspicious events, unusual activity, and trends.
Audit logs are written to Append Blobs in an Azure Blob storage account that
you designate. Audit policies can be applied at the server-level or database-
level. Once enabled, you can use the Azure portal to view the logs, or send
them to Log Analytics or Event Hub for further processing and analysis.
Auditing in practice
As a best practice, avoid enabling both server blob auditing and database blob
auditing together, unless:
You want to use a different storage account or retention period for a specific
database.
You want to audit event types or categories for a specific database that differs
from the rest of the databases on the server. For example, you might have
table inserts that need to be audited but only for a specific database.
Otherwise, it's recommended you enable only server-level blob auditing and leave
the database-level auditing disabled for all databases.
pg. 39
SKILLCERTPRO
Structured data
Structured data, sometimes referred to as relational data, is data that adheres to a
strict schema, so all of the data has the same fields or properties. The shared schema
allows this type of data to be easily searched with query languages such as SQL
(Structured Query Language). This capability makes this data style perfect for
applications such as CRM systems, reservations, and inventory management.
Structured data is straightforward in that it's easy to enter, query, and analyze. All of
the data follows the same format. However, forcing a consistent structure also means
evolution of the data is more difficult as each record has to be updated to conform
to the new structure.
Semi-structured data
Semi-structured data is less organized than structured data, and is not stored in a
relational format, as the fields do not neatly fit into tables, rows, and columns. Semi-
structured data contains tags that make the organization and hierarchy of the data
apparent - for example, key/value pairs. Semi-structured data is also referred to as
non-relational or NoSQL data. The expression and structure of the data in this style is
defined by a serialization language.
pg. 40
SKILLCERTPRO
XML, or extensible markup language, was one of the first data languages to
receive widespread support. It's text-based, which makes it easily human and
machine-readable. In addition, parsers for it can be found for almost all
popular development platforms. XML allows you to express relationships and
has standards for schema, transformation, and even displaying on the web.
JSON – or JavaScript Object Notation, has a lightweight specification and
relies on curly braces to indicate data structure. Compared to XML, it is less
verbose and easier to read by humans. JSON is frequently used by web
services to return data.
YAML – or YAML Ain’t Markup Language, is a relatively new data language
that’s growing quickly in popularity in part due to its human-friendliness. The
data structure is defined by line separation and indentation, and reduces the
dependency on structural characters like parentheses, commas and brackets.
Unstructured data
The organization of unstructured data is ambiguous. Unstructured data is often
delivered in files, such as photos or videos. The video file itself may have an overall
structure and come with semi-structured metadata, but the data that comprises the
video itself is unstructured. Therefore, photos, videos, and other similar files are
classified as unstructured data.
What is a transaction?
A transaction is a logical group of database operations that execute together.
Transactions are often defined by a set of four requirements, referred to as ACID
guarantees. ACID stands for Atomicity, Consistency, Isolation, and Durability:
OLTP vs OLAP
Transactional databases are often called OLTP (Online Transaction Processing)
systems. OLTP systems commonly support lots of users, have quick response times,
and handle large volumes of data. They are also highly available (meaning they have
very minimal downtime), and typically handle small or relatively simple transactions.
On the contrary, OLAP (Online Analytical Processing) systems commonly support
pg. 41
SKILLCERTPRO
fewer users, have longer response times, can be less available, and typically handle
large and complex transactions.
Name: Each storage account has a name. The name must be globally unique
within Azure, use only lowercase letters and digits and be between 3 and 24
characters.
Subscription: The Azure subscription that will be billed for the services in the
account.
Location: The datacenter that will store the services in the account.
Performance: Determines the data services you can have in your storage
account and the type of hardware disks used to store the data. Standard
allows you to have any data service (Blob, File, Queue, Table) and uses
magnetic disk drives. Premium allows you to create premium page blob in all
regions, and block blob accounts in supported regions. These storage
accounts use solid-state drives (SSD) for storage.
Replication: Determines the strategy used to make copies of your data to
protect against hardware failure or natural disaster. At a minimum, Azure will
automatically maintain a copy of your data within the data center associated
with the storage account. This is called locally-redundant storage (LRS), and
guards against hardware failure but does not protect you from an event that
incapacitates the entire datacenter. You can upgrade to one of the other
options such as geo-redundant storage (GRS) to get replication at different
datacenters across the world.
Access tier: Controls how quickly you will be able to access the blobs in this
storage account. Hot gives quicker access than Cool, but at increased cost.
This applies only to blobs, and serves as the default value for new blobs.
Secure transfer required: A security feature that determines the supported
protocols for access. Enabled requires HTTPs, while disabled allows HTTP.
Virtual networks: A security feature that allows inbound access requests only
from the virtual network(s) you specify.
pg. 42
SKILLCERTPRO
The number of storage accounts you need is typically determined by your data
diversity, cost sensitivity, and tolerance for management overhead.
Advanced settings
Secure transfer required setting controls whether HTTP can be used for the
REST APIs used to access data in the Storage account. Setting this option to
pg. 43
SKILLCERTPRO
Enabled will force all clients to use SSL (HTTPS). Most of the time you'll want
to set this to Enabled as using HTTPS over the network is considered a best
practice.
If Secured transfer(HTTPS) is enabled, it will enforce some additional restrictions.
Azure files service connections without encryption will fail, including scenarios
using SMB 2.1 or 3.0 on Linux. Because Azure storage doesn’t support SSL for
custom domain names, this option cannot be used with a custom domain name.
Large file shares provides support up to a 100TiB, however this type of
storage account can't convert to a Geo-redundant storage offering and
upgrades are permanent.
Blob Soft delete lets you recover your blob data in many cases where blobs
or blob snapshots are deleted accidentally or overwritten.
Data Lake Storage Gen2 option is for big-data applications.
A single Azure subscription can host up to 200 storage accounts, each of which can
hold 500 TB of data. If you have a business case, you can talk to the Azure Storage
team and get approval for up to 250 storage accounts in a subscription, which pushes
your max storage up to 125 Petabytes!
Blob storage
Azure Blob storage is an object storage solution optimized for storing massive
amounts of unstructured data, such as text or binary data. Blob storage is ideal for:
pg. 44
SKILLCERTPRO
Blob
Description
type
Append blobs are made up of blocks like block blobs, but they are
optimized for append operations. These are frequently used for
Append logging information from one or more sources into the same blob.
blobs For example, you might write all of your trace logging to the same
append blob for an application running on multiple VMs. A single
append blob can be up to 195 GB.
Files Azure Files enables you to set up highly available network file shares that can
be accessed by using the standard Server Message Block (SMB) protocol. This means
that multiple VMs can share the same files with both read and write access. You can
also read the files using the REST interface or the storage client libraries. You can also
associate a unique URL to any file to allow fine-grained access to a private file for a
set period of time. File shares can be used for many common scenarios:
Storing shared configuration files for VMs, tools, or utilities so that everyone is
using the same version.
Log files such as diagnostics, metrics, and crash dumps.
Shared data between on-premises applications and Azure VMs to allow
migration of apps to the cloud over a period of time.
pg. 45
SKILLCERTPRO
To work with data in a storage account, your app will need two pieces of data:
An access key - Each storage account has two unique access keys that are
used to secure the storage account.
The REST API endpoint - The REST endpoint is a combination of your storage
account name, the data type, and a known domain. For example:
o Blobs - https://[name].blob.core.windows.net/
o Queues - https://[name].queue.core.windows.net/
o Tables - https://[name].table.core.windows.net/
o Files - https://[name].file.core.windows.net/
Connection strings - The simplest way to handle access keys and endpoint URLs
within applications is to use storage account connection strings. A connection string
provides all needed connectivity information in a single text string.
DefaultEndpointsProtocol=https;AccountName={your-storage}; AccountKey={your-
access-key}; EndpointSuffix=core.windows.net
It's highly recommended that you periodically rotate your access keys to ensure they
remain private, just like changing your passwords. If you are using the key in a server
application, you can use an Azure Key Vault to store the access key for you. Key Vaults
include support to synchronize directly to the Storage Account and automatically rotate
the keys periodically. Using a Key Vault provides an additional layer of security, so your
app never has to work directly with an access key.
pg. 46
SKILLCERTPRO
Encryption at rest
All data written to Azure Storage is automatically encrypted by Storage Service
Encryption (SSE) with a 256-bit Advanced Encryption Standard (AES) cipher. This
incurs no additional charges and doesn't degrade performance. It can't be disabled.
For virtual machines (VMs), Azure lets you encrypt virtual hard disks (VHDs) by using
Azure Disk Encryption. This encryption uses BitLocker for Windows images, and it
uses dm-crypt for Linux.
Azure Key Vault stores the keys automatically to help you control and manage the
disk-encryption keys and secrets. So even if someone gets access to the VHD image
and downloads it, they can't access the data on the VHD.
Encryption in transit
Keep your data secure by enabling transport-level security between Azure and the
client. Always use HTTPS to secure communication over the public internet. When
you call the REST APIs to access objects in storage accounts, you can enforce the use
of HTTPS by requiring secure transfer for the storage account. After you enable
secure transfer, connections that use HTTP will be refused. This flag will also enforce
secure transfer over SMB by requiring SMB 3.0 for all file share mounts.
CORS support
Azure Storage supports cross-domain access through cross-origin resource sharing
(CORS). CORS uses HTTP headers so that a web application at one domain can access
resources from a server at a different domain. By using CORS, web apps ensure that
they load only authorized content from authorized sources. CORS support is an
optional flag you can enable on Storage accounts. The flag adds the appropriate
headers when you use HTTP GET requests to retrieve resources from the Storage
account.
pg. 47
SKILLCERTPRO
RBAC roles that are scoped to a subscription, a resource group, a storage account, or
an individual container or queue.
Auditing access
Auditing is another part of controlling access. You can audit Azure Storage access by
using the built-in Storage Analytics service.
Storage Analytics logs every operation in real time, and you can search the Storage
Analytics logs for specific requests. Filter based on the authentication mechanism,
the success of the operation, or the resource that was accessed.
Azure Storage accounts can create authorized apps in Active Directory to control access
to the data in blobs and queues. This authentication approach is the best solution for
apps that use Blob storage or Queue storage. For other storage models, clients can use
a shared key, or shared secret. This authentication option is one of the easiest to use,
and it supports blobs, files, queues, and tables.
You can use a service-level shared access signature to allow access to specific
resources in a storage account. You'd use this type of shared access signature,
for example, to allow an app to retrieve a list of files in a file system or to
download a file.
Use an account-level shared access signature to allow access to anything that
a service-level shared access signature can allow, plus additional resources
and abilities. For example, you can use an account-level shared access
signature to allow the ability to create file systems.
pg. 48
SKILLCERTPRO
Azure Blob storage is unstructured, meaning that there are no restrictions on the
kinds of data it can hold. Blobs aren't limited to common file formats — a blob could
contain gigabytes of binary data streamed from a scientific instrument, an encrypted
message for another application, or data in a custom format for an app you're
developing.
Blobs are usually not appropriate for structured data that needs to be queried
frequently. They have higher latency than memory and local disk and don't have the
indexing features that make databases efficient at running queries. However, blobs
are frequently used in combination with databases to store non-queryable data. For
example, an app with a database of user profiles could store profile pictures in blobs.
Blobs are used for data storage in many ways across all kinds of applications and
architectures:
pg. 49
SKILLCERTPRO
Apps that need to transmit large amounts of data using messaging system
that supports only small messages. These apps can store data in blobs and
send the blob URLs in messages.
Blob storage can be used like a file system for storing and sharing documents
and other personal data.
Static web assets like images can be stored in blobs and made available for
public download as if they were files on a web server.
Many Azure components use blobs behind the scenes. For example, Azure
Cloud Shell stores your files and configuration in blobs, and Azure Virtual
Machines uses blobs for hard-disk storage.
In Blob storage, every blob lives inside a blob container. You can store an unlimited
number of blobs in a container and an unlimited number of containers in a storage
account. Containers are "flat" — they can only store blobs, not other containers.
Blobs and containers support metadata in the form of name-value string pairs. Your
apps can use metadata for anything you like: a human-readable description of a
blob's contents to be displayed by the application, a string that your app uses to
determine how to process the blob's data, etc.
Apps using blobs as part of a storage scheme that includes a database often don't
need to rely heavily on organization, naming, or metadata to indicate anything about
their data. Such apps commonly use identifiers like GUIDs as blob names and
reference these identifiers in database records. The app will use the database to
determine where blobs are stored and the kind of data they contain.
Other apps may use Azure Blob storage more like a personal file system, where
container and blob names are used to indicate meaning and structure. Blob names in
these kinds of apps will often look like traditional file names and include file name
extensions like .jpg to indicate what kind of data they contain. They'll use virtual
directories (see below) to organize blobs and will frequently use metadata tags to
store information about blobs and containers.
pg. 50
SKILLCERTPRO
pg. 51