Azure Developer Guide Ebook en-GB
Azure Developer Guide Ebook en-GB
Azure Developer Guide Ebook en-GB
The Developer’s
Guide to Azure
Published May 2019
May The Developer’s 2
2019 Guide to Azure
03 / 40 / 82 /
Introduction Chapter 3: Securing Chapter 6: Where
your application and how to deploy
We’re here to help
your Azure services
How can Azure help secure
05 / your app?
Encryption
How can Azure deploy your
services?
Chapter 1: Getting Azure Security Center Infrastructure as Code
started with Azure Logging and monitoring Azure Blueprints
Containers in Azure
51 /
What can Azure do for you? Azure Stack
Where to host your Where to deploy,
application and when?
Chapter 4: Adding
Azure App Service Features
intelligence to
Azure Functions
Azure Logic Apps your application 89 /
Azure Batch
Containers How can Azure integrate AI
Chapter 7: Share your
What to use, and when? into your app? code, track work and ship
Making your application Azure Search software
more performant Cognitive Services
Azure Front Door Azure Bot Service How can Azure help you plan
Azure Content Delivery Azure Machine Learning smarter, collaborate better and ship
Network Studio your apps faster?
Azure Redis Cache Developer tooling for AI Azure Boards
AI and mixed reality Azure Repos
22 /
Using events and messages in Azure Pipelines
your application Azure Test Plans
Azure Artifacts
Chapter 2: Connecting
your app with data 72 /
What can Azure do for Chapter 5: Connect your
98 /
your data? business with IoT Chapter 8: Azure in Action
Where to store your data
Azure Cosmos DB How can Azure connect, secure, Walk-through: Azure portal
Azure SQL Database manage, monitor and control your Walk-through: Developing a web
Azure databases for MySQL, devices in the cloud? app and database
PostgreSQL and MariaDB Azure IoT Hub Walk-through: Extending apps
Azure Storage Azure IoT Central Walk-through: Ready for production
Azure data analytics Azure IoT solution accelerators
Azure IoT Edge
119 /
solutions
Walk-through: Publish an on- Azure Digital Twins
premises website to Azure with a Azure Sphere
SQL database Learn more about Azure IoT Chapter 9: Summary
What to use, and when? and resources
The
This guide is designed for developers and
architects who are starting their journey into
Microsoft Azure. In this guide, we’ll take you
through the ins and outs of Microsoft Azure.
Developer’s
You’ll learn how to get started and which
services you can use for the scenarios you
might have.
Azure
the heavy lifting for you. Azure services are
designed to work together so you can build
complete solutions that last the lifetime of
your app.
May The Developer’s 4
2019 Guide to Azure
With our support plans, you’ll get access to Azure Service Licence Agreements (SLAs), which can
technical support teams, guidance for cloud design inform you about our uptime guarantees and
and assistance with migration planning. You can downtime credit policies.
even acquire a support plan that guarantees a
@AzureSupport on Twitter, which is operated by
response from the technical support teams
skilful Azure engineers who respond quickly to
within 15 minutes.
issues that you tweet to them.
01 /
Mus ma dolor Duntiaspel is vel estotatem qui qui sitatio
nsedit, ea sere volor molupta dolut officto
Getting
You’ve made the decision to build applications
dolum earum minctur simillab is arum quatinverro
on Azure, and now you want to get started. You
te destibus, tem adis eum rehenia si
don’t need to do much – just sign up for an Azure
omnimusam
free account. veni nossita.
This includes credits to explore paid
started
Azure services and over 25 services you can use for
free forever.
with
Simply choose which tools, applications and
frameworks you want to use, and then start
running your apps on Azure.
Azure
May The Developer’s 6
2019 Guide to Azure
• A cloud platform
• Developer tools
• Management services
your application Web Apps: As one of the most widely used Azure
services, Web Apps can host your web applications
or APIs. A web app is basically an abstraction of a
web server, like Internet Information Services (IIS)
Azure offers services designed to provide what you or Tomcat, used to host HTTP-driven applications.
need to deliver and scale every application. When Web Apps can host applications written in .NET,
you use Azure services to run your application, you Node.js, Python, Java or GO, and you can use
get scalability, high availability, a fully managed available extensions to run even more languages.
platform and database services. Azure also offers
the following options for running your application.
// T
ry it out: Create an ASP.NET
Core web app in Azure
Azure App Service
You can host your applications in a fully managed Mobile Apps: Provide a back end for your mobile
application platform loved by enterprise applications with Mobile Apps. When you host
developers: Azure App Service. Azure App Service an API in Mobile Apps, your mobile applications
is a collection of hosting and orchestrating services connect with it through the cross-platform client
that share features and capabilities. All services in SDK. This is available for iOS, Android and Windows.
App Service have the capability, for example, to Mobile Apps provides features like offline sync and
secure an application using Azure Active Directory push notifications to help you create a modern,
and can use custom domains. performant and secure mobile experience.
May The Developer’s 8
2019 Guide to Azure
Azure App
You can even use Azure’s Testing in Production
feature to route a percentage of traffic from your
Service features
production app to a deployment slot. For example,
if you shunt 10% of your users to the new version
of your app in the deployment slot, you can see
whether the new features are functioning as
expected and whether users are using them.
Azure App Service is one of the key services in
Azure that you can use to host your applications. When you’re satisfied with how the new version of
Each of these services brings unique capabilities to your app is performing in the deployment slot, you
the table, but they all share some common features: can carry out a ‘swap’, which exchanges the app in
the deployment slot with that in your production
Scaling slot. You can also swap from a development slot to a
staging slot, and then to the production slot. Before
Azure App Service runs on App Service plans, doing this, the swap operation verifies that the new
which are abstractions from virtual machines (VMs). version of your website is warmed up and ready
One or more VMs run your Azure App Service, but to go. When this has been confirmed, the swap
since Azure takes care of them, it’s not necessary for operation switches the slots, and your users now see
you to know which ones. You can, however, scale the new version of the app – with no downtime. You
the resources that run your Azure App Service. can also swap back and revert the deployment of
the new version.
You can either choose a higher pricing tier (ranging
from free to premium) or increase the number of You use deployment slots within environments, such
application instances that are running. It’s even as development, test or production. You don’t use
possible to have even have Azure App Service deployment slots as environments, because they all
automatically scale the number of instances for you, reside in the same App Service plan.
based on a schedule or metrics like CPU, memory or
HTTP queue length. Those should be separated for security, scaling,
billing and performance. You can swap deployment
Deployment slots slots manually through the Azure command-line
interface (CLI) and through the Azure Management
After deploying a new version of your application to API. This allows tools like Azure DevOps to perform
a deployment slot, you can test whether it works as swap operations during a release.
expected and then move it into your production slot.
May The Developer’s 9
2019 Guide to Azure
You can connect external resources like data stores In a multi-tier web application, you often have a
to your App Services. These resources don’t need database or services used by your app in Web Apps.
to be located in Azure; they can be anywhere, Ideally, you want these services to be exposed only
such as on-premises or in your own datacentre. to the app and not to the internet. Given that it
Depending on your requirements, you can connect provides the entry point for your users, however,
to services on-premises through many mechanisms, the app itself is often internet-facing.
such as Azure Hybrid Connections, Azure Virtual
To isolate these support services from the internet,
Networks and Azure ExpressRoute.
you can use Azure Virtual Network.
May The Developer’s 10
2019 Guide to Azure
This service wraps your support services and The debugger lets you see exactly what went wrong
connects them to your app in Web Apps so that the without impacting the traffic of your production
support services are exposed only to the app, not to application. The Snapshot Debugger can help you
the internet. dramatically reduce the time it takes to resolve
issues that occur in production environments.
This article describes this service in more detail and
Additionally, you can use Visual Studio to set snap
shows you how to use it.
points to debug step by step.
Sometimes, you want even more control. Maybe
you want your app to be wrapped in a Virtual Automatic OS and .NET Framework
Network in order to control access to it. patching
Perhaps you want it to be called by another app in Because you’re using a fully managed platform, you
Web Apps and be a part of your back end. don’t manage your own infrastructure at all and
benefit from automatic operating system (OS) and
For this scenario, you can use an Azure App Service
framework patching.
Environment. This affords you a very high scale and
gives you control over isolation and network access. Virtual machines
Azure
An application that uses Functions activates a
function every time a new image file is uploaded
Functions
to Azure Blob storage. The function then resizes
the image and writes it to another Blob storage
account.
Azure
The following is an example of a workflow
in Logic Apps:
// T
ry it out: Get started with
Logic Apps has many available connectors to APIs
Azure Logic Apps
that can connect to Azure SQL Database, Salesforce,
SAP and so on.
Azure Batch
If you need to run large-scale batch or high-
performance computing (HPC) applications on
VMs, you can use Azure Batch. Batch creates and
manages a collection of thousands of VMs, installs
the applications you want to run and schedules jobs
on the VMs. You don’t need to deploy and manage
individual VMs or server clusters; Batch schedules,
manages and auto-scales your jobs so you use only
the VMs you need.
// T
ry it out: Get started on
Azure Batch with these
step-by-step tutorials
May The Developer’s 14
2019 Guide to Azure
Containers
masters. As a managed Kubernetes service, AKS
provides automated Kubernetes version upgrades
and patching, easy cluster scaling, a self-healing
hosted control plane (masters) and cost savings,
since you only pay for running agent pool nodes.
While much more lightweight, containers are
similar to VMs, and you can start and stop them in
With Azure handling the management of the nodes
a few seconds. Containers also offer tremendous
in your AKS cluster, there are many tasks that you
portability, which makes them ideal for developing
don’t have to perform manually, such as cluster
an app locally, on your machine and then hosting
upgrades. Because Azure handles these critical
it in the cloud, in test and later in production.
maintenance tasks for you, AKS does not provide
direct access (such as with SSH) to the cluster.
You can even run containers on-premises or in other
clouds – the environment that you use on your
development machine travels with your container,
so your app always runs in the same ecosystem. // M
ore information: Learn how
to use Azure Kubernetes Service
// More
information: Learn more
about Azure Container Instances
May The Developer’s 15
2019 Guide to Azure
What to use,
Some of the services that run your application in
Azure can work together in a solution, while others
and when?
are more suited to different purposes.
Table 1-1
Web Apps*
Containers*
Web App for
Mobile Apps*
Functions*
Logic Apps*
Machines*
Virtual
Service*
Kubernetes
Fabric*
Service
Instances*
Container
Batch*
Monolithic and
N-Tier applications ● ●** ● ●
Mobile app
back end ● ●**
Microservice
architecture ● ● ●
applications
Business process
orchestration ● ●
and workflows
Compute
intensive jobs ●
* Services with an asterisk have a free tier that you can use to get started at no cost.
Making your
Azure Traffic Manager scales across regions,
helping to reduce latency and provide users a
application more
performant experience, regardless of where they
are. Traffic Manager is an intelligent routing
mechanism that you put in front of your Web Apps
After your application is up and running in Azure, When users access your application, Traffic Manager
you want it to be as performant as possible. Azure routes them to the Web Apps application that is
provides a range of services that can help you most performant in their proximity.
with that.
Including Traffic Manager in your architecture is
Azure Traffic Manager a great way to improve the performance of your
application.
Many modern applications have users all over
the world. Providing a performant experience for
everyone is challenging, to say the least. The most
obvious problem you need to deal with is latency,
the time it takes for a signal or a request to travel
to a user. The farther away users are from your
application, the more latency they experience.
May The Developer’s 18
2019 Guide to Azure
Azure
Azure Front Door can help. This service can
route traffic from users to the most performant
Front Door
application endpoint for them to improve
performance. Azure Front Door can route to
endpoints that are available while avoiding
endpoints that are down.
Your users might be spread out over the world Azure Traffic Manager does this as well, but in a
and at times might be travelling. This can make different manner than Azure Front Door. Azure
it difficult to make sure they have a performant Front Door works at OSI layer 7 or the HTTP/
experience and that your application is available HTTPS layer, while Azure Traffic Manager works
and secure, regardless of location. with DNS. In other words, Azure Front Door works
on the application level and Azure Traffic Manager
works on the network level. This is a fundamental
difference that determines the capabilities of the
services.
You need application layer features like URL rewriting and WAF ●
May The Developer’s 20
2019 Guide to Azure
Azure Content
Not only is this easy to do, it also improves
the performance of your application in the
Delivery Network
following ways:
02 /
Mus ma dolor Duntiaspel is vel estotatem qui qui sitatio
nsedit, ea sere volor molupta dolut officto
Connecting
dolum earum minctur simillab is arum quatinverro
te destibus, tem adis eum rehenia si
omnimusam veni nossita.
your app
with data
May The Developer’s 23
2019 Guide to Azure
Where to store
your data
Azure provides many types of data stores that can All services have a free tier that you can use
help you maintain and retrieve data in any scenario. to get started.
Table 2-1 presents the storage options available
in Azure.
// N
ote: You can use almost all
storage options mentioned in
this section as activators and
bindings for Azure Functions.
Table 2-1
SQL Database*
MySQL*
PostgreSQL*
MariaDB*
DB*
A zure Cosmos
Blob*
Table*
Queue*
File*
Disk*
Warehouse*
SQL Data
Relational data ● ● ● ● ● ●
Unstructured data ● ● ●
Semi-structured data ● ●
Queue messages ●
Files on disk ●
* Services with an asterisk have a free tier that you can use to get started at no cost.
May The Developer’s 25
2019 Guide to Azure
Azure Cosmos DB
In addition to all these features, Azure Cosmos DB
offers different APIs with which you can store and
retrieve data, including SQL, JavaScript, Gremlin,
MongoDB, Azure Table Storage and Apache
Cassandra. Different APIs handle data in different
Azure Cosmos DB is a new kind ways. You can use documents as data as well as
of database made for the cloud. unstructured tables, graphs and blobs. You use the
Its key features include: API that fits your needs and Azure Cosmos DB takes
care of the rest.
• A 99.99% SLA (99.999% for read operations) that
includes low latencies (less than 10 ms on reads
You benefit from cloud-grade performance,
and less than 15 ms on writes)
scalability and reliability while using the
programming model you’re already accustomed to.
• Geo-replication, which replicates data to other
geographical regions in real time.
// T
ry it out: Get started with
Azure Cosmos DB
• Tunable data consistency levels so you can
enable a truly globally distributed data system.
You can choose from a spectrum of data
consistency models, including strong consistency,
session consistency and eventual consistency.
Azure SQL
• Auditing, which provides a complete audit trail
of all the actions that happen to the data
If you want to use tables with columns and rows to SQL Database offers several service tiers
store data, Azure SQL Database is a great choice. that are geared toward specific scenarios.
A relational database system similar to on-premises
Microsoft SQL Server, SQL Database runs in the • General purpose/standard: This tier offers
cloud – so it’s fully managed, performant, scalable, budget-oriented, balanced and scalable
automatically backed up and includes many compute and storage options. Fully managed,
advanced features. with performance comparable to Azure SQL
VMs, this tier is the best option for most
With SQL Database, you can do almost everything business workloads.
that you can do with on-premises SQL Server. In
• Business Critical/Premium: This tier offers
fact, new SQL Server features are incorporated first
the highest resilience to failures using several
in Azure SQL Database and later in on-premises SQL
isolated replicas. With consistently high IO, it
Server.
includes a built-in availability group for high
availability. This is the best option for critical
You can use SQL Database with your favourite tools,
Online Transactional Processing (OLTP) (normal
including SQL Server Management Studio and the
CRUD operations) business applications with
Entity Framework. Databases in SQL Database are
consistently high IO requirements.
extremely reliable and robust and offer an SLA that
guarantees 99.99% uptime. • Hyperscale: This tier offers very large database
(VLDB) support without the headaches. With
Here are some of the more advanced features in a built-for-the-cloud architecture of highly
SQL Database: scalable storage and a multilayer cache
optimised for very large and demanding
• Geo-replication, which replicates data to other workloads, it provides low latency and high
geographical regions in real time throughput regardless of the size of data
operations. This is the best tier for very large
• Dynamic data masking, which masks sensitive
and demanding workloads with highly scalable
data for certain users at runtime
storage and read-scale requirements.
May The Developer’s 27
2019 Guide to Azure
Azure databases
Azure provides MySQL, PostgreSQL and MariaDB
databases as managed databases, which means
for MySQL,
that you just spin them up and don’t have to worry
about any of the underlying infrastructure. Just like
Azure SQL Database and Azure Cosmos DB, these
Queue
and Block Blobs. Page Blobs are optimised for
Blob Table
Unstructured Semi-structured Queue random read and write operations, and are perfect
Large Flexible scheme Reliable
MSMQ
for storing a VHD. Block Blobs are optimised for
Page/Block Small messages
efficiently uploading large amounts of data.
File Disk
File share Premium High I/O
SMB VM Disks
Figure 2-1
May The Developer’s 29
2019 Guide to Azure
These are perfect for storing large video files that File storage
don’t change often. Append Blobs are optimised for
append operations, such as storing operation logs You can use Azure File storage as a drive to share
that can’t be updated or deleted. files from. It uses the Server Message Block (SMB)
protocol, meaning you can use it with Windows and
// T
ry it out: Get started with Linux and access it from either the cloud or on-
Azure Blob storage premises systems. Like the other services in Azure
Storage, File storage is scalable and inexpensive.
Table storage
// T
ry it out: Get started with
Azure Table storage is an inexpensive, extremely Azure File storage
fast NoSQL key-value store you can use to store
data in flexible tables. A table can contain one row Disk storage
describing an order and another row describing
customer information. You don’t need to define Azure Disk storage is similar to File storage, but
a data schema, making Table storage very flexible. is specifically meant for high I/O performance.
It’s perfect for use as a drive in a VM that needs
// T
ry it out: Get started with high performance to run SQL Server, for instance.
Azure Table storage
Disk storage is available only in the premium
pricing tier of Azure Storage.
Queue storage
Azure Data Lake Store
Azure Queue storage is an unusual type of storage.
While it’s used to store small messages of data,
The previous data stores were meant for
its main purpose is to serve as a queue. You put
regular application use or for use with VMs.
messages on the queue and other processes pick
The Azure Data Lake Store, on the other hand,
them up. This pattern decouples the message
is storage for big data applications. You can use it
sender from the message processor, resulting in
to store large amounts of data in its native format –
performance and reliability benefits. Azure Queue
structured, unstructured or anything in between.
storage is found in previous versions of Windows.
The point of the Data Lake Store is to hold your raw
data so you can analyse it or transform and move it.
// T
ry it out: Get started with
Azure Queue storage
May The Developer’s 30
2019 Guide to Azure
The following are the main characteristics of in predefined schemas and query it by using the
Azure Data Lake Store: familiar SQL Server dialect.
• Unlimited storage capacity. A single file can be Because SQL Data Warehouse runs in Azure, there
larger than one petabyte in size – 200 times larger are many advanced features available to you. One of
than other cloud providers offer. these features is automatic threat detection, which
uses machine learning to understand the patterns of
• Scalable performance to accommodate massively your workload and serve as an alarm system to alert
parallel analytics. you of a potential breach.
• Data can be stored in any format, without a An effective time to use SQL Data Warehouse is
schema. when you know which reports you want to show
to users and what the data schema for these
This is a very different approach from the traditional reports is. You can then create schemas in SQL Data
data warehouse, in which you define data schemas Warehouse and populate it with data so users can
upfront. navigate through the data.
You can store all of the data that you get from // T
ry it out: Create an Azure SQL
Internet of Things (IoT) devices collecting Data Warehouse
temperature data, for example, in Data Lake
Storage. You can leave the data in the store and
then filter through it to create a view of the data
per hour or per week. Storing the data in Data Lake
Storage is inexpensive, so you can keep years of
data there at a very low cost.
// T
ry it out: Get started with
Azure Data Lake Store using the
Azure portal
Azure data
When you move data, you can also filter it before
you send it to an end destination, clean it up or
analytics
transform it with an activity in the pipeline like
the Apache Spark activity. In addition, Azure
Data Factory allows you to schedule and monitor
// T
ry it out: Create a data factory
Almost as important as storing data is analysing it to using the Azure portal
get insights. Azure provides many services for data
analytics scenarios, enabling you to get valuable Azure Analysis Services
and actionable insights from your data – no matter
how large or small or complex it is. With Azure Analysis Services, you can create a
semantic model of your data that users can access
Azure Data Factory directly with visualisation tools like Power BI. Built
on the SQL Server Analysis Services tools that run
Moving and transforming data is not a trivial on-premises with SQL Server, the service now runs
task, but Azure Data Factory can help you to managed in the cloud. This means that the service
do just that. Within Data Factory, you can create is scalable and that data is stored redundantly – and
a comprehensive pipeline that performs your when you aren’t using it, you can pause the service
complete extraction, transformation and loading to minimise costs.
(ETL) process.
With Azure Analysis Services, you can provide
Data Factory can reliably move data from on- modelled data directly to users in a very performant
premises to the cloud, within the cloud or to way. Users can query millions of records in seconds
on-premises – it doesn’t matter where your data because the model lives completely in memory and
sources are. Data Factory also provides many is periodically refreshed.
connectors that you can use to easily connect to
your data source, like SQL Server, Azure Cosmos DB, You can get data into the semantic model from
Oracle and many more. anywhere, including from data sources in the cloud
and on-premises. You can use Azure Blob storage,
May The Developer’s 32
2019 Guide to Azure
Azure SQL Database, Azure SQL Data Warehouse Azure Stream Analytics
and many other services as data sources for the
model. You can also use data sources like on- You can use the Azure Stream Analytics service
premises Active Directory, Access databases and to analyse, query and filter real-time streaming
Oracle databases. data. For example, when you receive a stream of
temperature data from an IoT device, it tells you
// T
ry it out: Create an Azure how warm it is outside. It might provide the same
Analysis Services server using temperature every second for an hour until the
the Azure portal temperature changes, but you are only interested in
the changes. Azure Stream Analytics can query the
Azure Data Lake Analytics data in real time and store only the differential data
in an Azure SQL Database.
Another Azure service for performing data analytics
tasks is Azure Data Lake Analytics. With this service, Stream Analytics can get its data from many
you can analyse, process and transform potentially services, including Azure Blob storage, Azure Event
massive amounts of data from Azure Storage and Hubs and Azure IoT Hub. You can analyse the data
Azure Data Lake Store. by using a simple SQL-like language or custom
code. After querying and filtering the stream of
Azure Data Lake Analytics allows you to create and data, Stream Analytics can output the result to many
submit jobs that query data, analyse it or transform Azure services, including Azure SQL Database, Azure
it. You can write these jobs in U-SQL, which is a SQL- Storage and Azure Event Hubs.
like language and extend U-SQL with Microsoft R
and Python. // T
ry it out: Create a Stream
Analytics job using the
You pay for the jobs that you submit and run, and Azure portal
the service scales automatically depending on the
power that the jobs need. Azure Data Lake Analytics Azure Time Series Insights
is typically used for long-running analytics jobs
against massive amounts of data. You can use Azure Time Series Insights to get quick
insights on large amounts of typically IoT-type data.
// T
ry it out: Create your first This service gets data from Azure Event Hubs, IoT
U-SQL script through the Hub and your own reference inputs, and it retains
Azure portal that data for a specified amount of time.
May The Developer’s 33
2019 Guide to Azure
With Azure Time Series Insights, users can query and Azure Data Lake Store. Databricks also works with
analyse data through a visualisation tool as soon as data from Azure SQL Data Warehouse, Azure SQL
it comes in. Time Series Insights not only analyses Database and Azure Cosmos DB. Additionally, you
data, but also ingests and holds it for a while. This can plug Databricks into Power BI to create and
is like Azure Analysis Services, where data lives show powerful dashboards.
in-memory in a model for users to query. The key
differences are that Time Series Insights is optimised // T
ry it out: Run a Spark job on
for IoT and time-based data, and it contains its own Azure Databricks using the
data visualisation tool. Azure portal
// T
ry it out: Explore a Time Series Azure HDInsight
Insights demo environment from
your browser Azure HDInsight is a platform within Azure that you
can use to run open-source data analytics services.
Azure Databricks You can also use it to run specialised clusters of
your favourite open-source data analytics tools.
Azure Databricks allows you to run a managed and The advantage of running these tools in Azure
scalable Databricks cluster in the cloud. Databricks HDInsight is that they’re managed, which means
provides a unified analytics platform with a host you don’t have to maintain VMs or patch operating
of tools and capabilities. Within Databricks, you systems. Plus, they can scale and easily connect to
can run optimised versions of Apache Spark to do one another, other Azure services and on-premises
advanced data analytics. data sources and services.
In addition to Spark-based analytics, Databricks Most of the specialised open-source data analytics
provides interactive notebooks and integrated cluster types in Azure HDInsight use Azure Blob
workflows and workspaces you can use to storage or Azure Data Lake Store to access or store
collaborate with the entire data team, including data, as these services work with the Hadoop File
data scientists, data engineers and business analysts System.
– all of whom have access to specialised tools for
their specific needs. You can run potentially massive specialised clusters
of different types, such as an Apache Hadoop
Databricks is fully integrated with Azure Active cluster. This enables you to process and analyse
Directory, which gives you the ability to implement data with Hadoop tools like Hive, Pig and Oozie.
granular security. With Databricks, you can perform
Spark-based data analytics on data that comes
from many places, including Azure Storage and
May The Developer’s 34
2019 Guide to Azure
You can also spin up an Apache HBase cluster, This allows you to run R-based jobs to analyse data.
which provides a very fast NoSQL database. The Finally, you can create a cluster that runs Apache
data actually lives within Azure Storage or an Azure Kafka, which is a publish-subscribe messaging
Data Lake, but HBase provides an abstraction layer system used to build applications with
on top, which has its own functionality and unique queueing mechanisms.
performance.
There are more cluster types, as well as tools that
You can create an Apache Storm cluster, which you can use within clusters. You can perform
is geared toward analysing data streams, just like almost any data analytics and processing task with
Azure Stream Analytics. In addition, you can have an a combination of these clusters, and they all run
Apache Spark cluster, which provides a framework managed in the cloud. Table 2-2 can help you pick
for processing and analysing massive amounts of the right Azure services for analysing your data.
data. HDInsight can also run a cluster for Microsoft
Machine Learning Server (previously Microsoft R // T
ry it out: Extract, transform
server). and load data using Apache Hive
on Azure HDInsight
Table 2-2
Time Series Insights*
Data Factory*
Analysis Services*
Stream Analytics*
Azure Databricks*
Azure HDInsight*
Transform data ● ● ● ● ● ● ●
* Services with an asterisk have a free tier that you can use to get started at no cost.
May The Developer’s 35
2019 Guide to Azure
Publish an on-
• Microsoft Visual Studio 2017 or later
premises website •
this demo script
to Azure with
a SQL database
Walk through: Migrating a .NET app to Azure without
code change
Rewards clone
Publish app
May The Developer’s 37
2019 Guide to Azure
Publish options
Create profile
May The Developer’s 38
2019 Guide to Azure
Publish app
May The Developer’s 39
2019 Guide to Azure
Publish Succeeded
Web app
Further reading
// G
uide to NoSQL with Azure
Cosmos DB
03 /
Mus ma dolor Duntiaspel is vel estotatem qui qui sitatio
nsedit, ea sere volor molupta dolut officto
Securing
dolum earum minctur simillab is arum quatinverro
te destibus, tem adis eum rehenia si
omnimusam veni nossita.
your
application
May The Developer’s 41
2019 Guide to Azure
How can
Azure help
secure your app?
Have you ever had a security incident with one of
your applications? You might have had one without
even knowing it. With Azure, you can protect
data, apps, and infrastructure with built-in security
services that include security intelligence to help
identify rapidly evolving threats early – so you can
respond quickly.
Azure Active Directory (Azure AD) provides all control the secrets and developers never need to
of these things and more out of the box. You deal with them. Key Vault also stores SSL and other
store your user identities in Azure AD and have certificates used to secure the traffic to and from
users authenticate against it, redirecting them to your applications over HTTPS.
your application only after they’re authenticated.
Azure AD takes care of password management,
Azure Sentinel
including resolving common scenarios like
forgotten passwords.
To get a good overview of the security status of
your organisation and all of its users, applications,
Since Azure AD is used by millions of applications
services and data, you can use a security
every day – including the Azure portal, Outlook.
information and event manager (SIEM) platform.
com and Office 365 – it’s able to more readily
Azure now offers an AI-powered SIEM in the form
detect and act on malicious behaviour. For instance,
of Azure Sentinel.
if a user were to sign in to an application from a
location in Europe and then one minute later sign in
Use Azure Sentinel to collect data from your
from Australia, Azure AD would flag this as malicious
organisation, including data about users,
behaviour and ask the user for additional credentials
applications, servers and infrastructure assets like
through multifactor authentication.
firewalls and devices running in the cloud and
on-premises. It’s easy to collect data from your
Azure Key Vault organisation with the built-in connectors. As data
is being collected, Azure Sentinel detects security
As part of your security architecture, you need a
threats and minimises false positives with its smart
secure place to store and manage certificates, keys
machine learning algorithms.
and other secrets. Azure Key Vault provides this
capability. With Key Vault, you can store the secrets
When there’s a threat, you’ll be alerted and
that your applications use in one central location.
can investigate it with AI, utilising decades of
cybersecurity work at Microsoft. You can respond
These secrets can include the credentials in a
to incidents with Azure Sentinel’s built-in workflow
connection string. Your application would get the
orchestration and task automation.
connection string from Key Vault instead of from the
configuration system. This way, administrators can
// G
et started by onboarding
Azure Sentinel
// T
ry it out: Get started with
Azure Key Vault
May The Developer’s 43
2019 Guide to Azure
APIs should be secure. This is true for APIs you Azure AD Application Proxy provides single
create yourself as well as those from third-party sign-on (SSO) and secure remote access for web
vendors. To assist in making your APIs secure, you applications hosted on-premises. Apps you would
can use Azure API Management. This is basically likely want to publish include SharePoint sites,
a proxy you put in front of APIs that adds features Outlook Web Access or other line-of-business
like caching, throttling and authentication or (LOB) web applications. These on-premises web
authorisation. apps integrate with Azure AD, the same identity
and control platform used by Office 365. End users
With API Management, you secure an API by can access your on-premises applications the same
requiring users to create a subscription to it. This way they access Office 365 and other SaaS apps
way, applications need to authenticate before they integrated with Azure AD.
can use your API. You can use various authentication
methods like access tokens, basic authentication Managed Identities for Azure resources
and certificates. Additionally, you can track who’s
calling your API and block unwanted callers. How do you keep credentials out of your code
completely? You can start by using Azure Key Vault,
Much more than security but where do you store the credentials to connect to
Key Vault? Managed Identities for Azure resources
While security is critical, Azure API Management provides a solution.
offers other capabilities that can help streamline
your development and testing workflow, such as You can use Managed Identities for a lot of services
test data response mocking, publishing multiple in Azure, including Azure App Service. You simply
API versions, introducing non-breaking changes enable Managed Identity with a button to inject
safely with revisions and giving developers access credentials into your application at runtime and
to your API’s auto-generated documentation, then use those credentials to access other services
catalogue and code samples. like Azure Key Vault. All authentication between
services is done on the infrastructure level, meaning
// T
ry it out: Get started with your application doesn’t have to deal with it and can
Azure API Management just use other services.
// T
ry it out: How to use
Managed Identities for Azure
resources in App Service and
Azure Functions
May The Developer’s 44
2019 Guide to Azure
Encryption
• SQL Transparent Data Encryption (TDE) encrypts
SQL Server, Azure SQL Database and Azure SQL
Data Warehouse data files. Data and log files are
encrypted using industry-standard encryption
algorithms. Pages in a database are encrypted
Default encryption of data
before they’re written to disk and decrypted when
they’re read.
By default, your data is encrypted in Azure when
stored in Azure SQL Database, Azure SQL Data
• SQL Always Encrypted encrypts data within
Warehouse, Azure Database for MySQL, Azure
client applications prior to storing it in Azure SQL
Database for PostgreSQL, Azure Storage, Azure
Database. It allows delegation of on-premises
Cosmos DB or Azure Data Lake Store. All this
database administration to third parties and
encryption works automatically, and you don’t need
maintains separation between those who own
to configure anything when you use it.
and can view the data and those who manage it,
but should not access it.
To help meet your security and compliance
requirements, you can use the following features
• Azure Cosmos DB requires no action from you –
to encrypt data at rest:
user data stored in Azure Cosmos DB in non-
volatile storage (solid-state drives) is encrypted
• Azure Disk Encryption encrypts Windows and
by default and there are no controls to turn it
Linux infrastructure as a service (IaaS) VM boot
on or off.
and data volumes using customer-managed keys.
Azure Security
You don’t have to do anything to enable the Basic
tier – it’s automatically enabled for every customer
Centre
as part of the Azure platform. This service protects
your applications against the most common DDoS
attacks by performing real-time monitoring and
mitigation, and it provides the same defences used
by Microsoft Online Services (MOS).
Azure Security Centre provides unified security
management and advanced threat protection The Standard tier provides additional mitigation
across hybrid cloud workloads. It offers centralised capabilities that are tuned specifically to Azure
policy controls to limit exposure to threats and Virtual Network resources. It’s simple to enable,
rapidly find and fix vulnerabilities. and you don’t have to change your applications –
everything is done at the network level. Plus, with
In addition, Security Centre supports integration the Standard tier you can customise the Basic tier
with third-party solutions and can be customised protection with your own policies that focus on your
with automation and programming capabilities. specific use cases and applications.
You can use Security Centre to analyse the security
state of your compute resources, virtual networks, // M
ore information: Read more about
storage and data services and applications. Azure DDoS protection
You’ve heard about it on the news and you certainly Because the traffic is encrypted, it’s secure – even
don’t want it to happen to your enterprise: an when it travels over the public internet. VPN
application is targeted by a Distributed Denial of Gateway can send encrypted traffic between Azure
Service (DDoS) attack. These types of attacks are virtual networks over the Microsoft network.
becoming more common and can overwhelm You can also create encrypted Point-to-Site (P2S)
your application to the point that no one can use it connections from your computer to Azure. This way,
anymore. The Azure DDoS protection service offers you have your own private, secured connection to
protection from DDoS attacks through a free tier Azure even when you’re on the road.
(Basic) and a paid tier (Standard).
May The Developer’s 46
2019 Guide to Azure
// G
et started by creating an Azure
Azure Network Watcher
VPN Gateway with PowerShell
Azure Network Watcher is a regional service that
enables you to monitor and diagnose conditions at
Azure Application Gateway the network level in, to and from Azure.
Azure Application Gateway is a dedicated virtual Its many diagnostic and visualisation tools can help
appliance that provides an application delivery you understand and gain deeper insights into your
controller (ADC) as a service. It offers various Layer 7 network in Azure.
load balancing capabilities for your application, and
allows customers to optimise web farm productivity Examples include:
by offloading CPU-intensive SSL termination to the
application gateway. The gateway also provides • Topology: Provides a network-level view showing
other Layer 7 routing capabilities, including round- the various interconnections and associations
robin distribution of incoming traffic, cookie-based between network resources in a resource group.
session affinity, URL path-based routing and the
ability to host multiple websites behind a single • Variable packet capture: Captures packet data in
application gateway. and out of a VM. Advanced filtering options and
fine-tuned controls, such as the ability to set time
Azure Web Application Firewall and size limitations, provide versatility. The packet
data can be stored in a blob store or on the local
You need to secure your application against
disk in .cap format.
many threats, including SQL injection, Cross-site
scripting (XSS) and others defined in the Open Web
• IP flow verify: Checks if a packet is allowed or
Application Security Project (OWASP). A WAF from
denied based on 5-tuple flow information and
Azure can lend a hand with that. A feature of the
packet parameters (destination IP, source IP,
Azure Application Gateway service, a WAF provides
destination port, source port and protocol). If the
real-time protection of your application. It detects
packet is denied by a security group, the rule and
malicious attacks, as defined in the OWASP core
group that denied the packet are returned.
rule set and blocks those attacks from reaching your
application. It also reports on attempted or ongoing
attacks so that you can see active threats to your
application, providing an extra layer of security.
May The Developer’s 47
2019 Guide to Azure
A network security group (NSG) holds a list of Azure supports two types of cross-premises VPN
security rules that allow or deny network traffic to connections: P2S VPN and S2S VPN. A P2S VPN
resources connected to Azure Virtual Networks. connection lets you create a secure connection
NSGs can be associated to subnets, individual VMs to your virtual network from an individual client
(classic-style VMs) or individual network interface computer. This type of connection is established
controllers (NICs) attached to VMs (Resource from the client computer, which is useful for
Manager‑style VMs). When an NSG is associated to telecommuters who want to connect to Azure
a subnet, the rules apply to all resources connected Virtual Networks from a remote location. A P2S VPN
to the subnet. You can restrict traffic even further by is also useful when you have only a few clients that
also associating an NSG to a VM or NIC. need to connect to a virtual network. In contrast,
an S2S VPN connection is used to connect your
Azure DNS Private Zones on-premises network to an Azure virtual network
over an IPsec/IKE (IKEv1 or IKEv2) VPN tunnel. This
The DNS is responsible for translating (or resolving) type of connection requires a VPN device located
a service name to its IP address. Azure DNS is a on-premises that has an externally facing public IP
hosting service for DNS domains, providing name address.
resolution using the Azure infrastructure. In addition
to internet-facing DNS domains, Azure DNS now // M
ore info: Read more about P2S
supports private DNS domains as a preview feature and S2S VPNs
with Azure DNS Private Zones. Security benefits
from private DNS zones include the ability to create
a split DNS infrastructure. This enables you to create
private and public DNS zones with the same names
without exposing internal names. In addition,
the use of DNS Private Zones removes the need
to introduce custom DNS solutions that could
increase the overall attack surface with independent
updating and management requirements.
// M
ore information: Read more
about DNS Private Zones
May The Developer’s 48
2019 Guide to Azure
Azure ExpressRoute
// M
ore info: Read about Load
Balancer and HA ports rules
May The Developer’s 49
2019 Guide to Azure
monitoring
A feature of Network Watcher, Azure NSG flow
logs allow you to view information about ingress
and egress IP traffic through an NSG. Flow logs can
be analysed to gain information and insights into
network traffic and security as well as performance
Azure Log Analytics issues related to traffic.
Azure Log Analytics helps you collect and analyse While flow logs target NSGs, they are not displayed
data generated by resources in your cloud and in the same way as other logs and are stored only
on-premises environments. It provides real-time within a storage account.
insights by using integrated search and custom
dashboards to analyse millions of records across Azure Monitor Application Insights
all your workloads and servers regardless of their
physical location. Azure Monitor Application Insights is an extensible
application performance management (APM)
Azure Monitor service for web developers on multiple platforms.
It includes powerful analytics tools to help you
Azure Monitor enables basic monitoring for Azure diagnose issues and understand what users do
services by collecting metrics, activity logs and with your app. It works for applications on a variety
diagnostic logs. The metrics collected provide of platforms hosted on-premises or in the cloud,
performance statistics for different resources, including .NET, Node.js and J2EE.
including the OS associated with a VM.
Application Insights integrates with your DevOps Azure security technical and architectural
process and has connection points to a variety of documentation
development tools. It can monitor and analyse
telemetry from mobile apps by integrating with Azure maintains a large library of security technical
Visual Studio App Centre. documentation that supplements security
information with individual services. White papers,
Azure Security and Compliance Blueprint best practices documents and checklists are
included on the Azure Security Information page.
The Azure Security and Compliance Blueprint –
HIPAA/HITRUST Health Data and AI provides tools Also covered are core public cloud security topics
and guidance to help deploy a platform as a service in diverse areas, including network security, storage
(PaaS) environment for compliance with the Health security, compute security, identity and access
Insurance Portability and Accountability Act (HIPAA) management, logging and auditing, cloud workload
and Health Information Trust Alliance (HITRUST). protection, PaaS security and more.
// M
ore information: Read more
// Azure for Architects
about the Azure Security and
Compliance Blueprint
February Lorem
May ipsum dolor sit
Theamet,
Developer’s
consectetur 51
2018 adipiscing
2019 elit Guide to Azure
04 /
Mus ma dolor Duntiaspel is vel estotatem qui qui sitatio
nsedit, ea sere volor molupta dolut officto
Adding
dolum earum minctur simillab is arum quatinverro
te destibus, tem adis eum rehenia si
omnimusam veni nossita.
intelligence
to your
application
May The Developer’s 52
2019 Guide to Azure
Table 4-1
Azure Search*
Services*
Azure Cognitive
Learning Studio*
Azure Machine
Learning*
Azure Machine
Anchors*
Azure Spatial
Rendering*
Azure Remote
Move data from store to store ●
Transform data ● ● ● ● ● ● ●
* Services with an asterisk have a free tier that you can use to get started at no cost.
May The Developer’s 54
2019 Guide to Azure
Azure Search
• User experience features like sorting and
paging search results, intelligent filtering
and providing search suggestions.
Cognitive
Each category in the table contains multiple
services that you can use by calling an API. Some
Services
categories contain custom services, like Custom
Vision, Language Understanding and Bing
Custom Search. These custom services provide
preconfigured machine learning algorithms,
just like the other services, and they also enable
Cognitive Services provides machine learning you to use your own data to train the model. In
algorithms, created by Microsoft, and data as addition to these services, you can use the services
a service. For most services, Microsoft has also in the Cognitive Services Labs. The labs contain
provided the data to train those algorithms. experimental services that Microsoft is trying out
For some services, you can use your own custom to see if they fit well with customer use cases. One
data to train the algorithms. such experimental service is Project Gesture, which
enables you to detect gestures like the wave of a
Cognitive Services provides an exceptionally easy hand and weave them into your user experience.
way to incorporate machine learning and AI into
your application – by simply calling APIs. Let’s take a closer look at some of the Cognitive
Services.
Table 4-2 shows which APIs are currently available.
Note that the list keeps growing.
// T
ry it out: Explore
Cognitive Services
All services have a free tier that you can use to get
started.
Table 4-2
Computer Vision Speech to Text Text Analytics Q&A Maker Bing Web Search
Face Text to Speech Translator Text Bing Visual Search
Video Indexer Speech Translation Bing Spell Check Bing Entity Search
Content Moderator Speaker Recognition Content Moderator Bing News Search
Custom Vision Language Bing Custom Search
Understanding Bing Image Search
Bing Autosuggest
Bing Video Search
Bing Local Business
Search
* All services have a free tier that you can use to get started.
May The Developer’s 56
2019 Guide to Azure
Language Understanding train the model. In this example, you would tag an
image with ‘cumulus’ or ‘stratus’.
Use the Language Understanding (LUIS) service
to understand what users are saying to you on Once you’ve uploaded enough images, you can
social media, in chatbots or in speech-enabled train your model. The more images you upload
applications. For example, you can book flights or with tags and the more training you do, the more
schedule meetings. accurate your model will be.
To use the Language Understanding service, give Once you have a model that performs well, you can
it examples of what you want it to understand, like start using it by making calls to the Custom Vision
‘Book a flight to Seattle’ or ‘Schedule a meeting API and feeding it new images. When you upload
at 1 pm with Bob’, and tell it which words you’re a new image, the service tells you if it recognises
looking for. In these examples, you might be looking it based on the images already uploaded.
for the destination of the flight (Seattle) and the Figure 4-1 shows an example of what the API
time and person for the meeting (1 pm and Bob). endpoint looks like.
// T
ry it out: Create a new app
in the LUIS portal
Custom Vision
This offers great flexibility because you don’t need • Performs sentiment analysis, which identifies
an active internet connection to use the capabilities when something positive, negative or
of the Custom Vision service; you can also run neutral is said or displayed.
it locally, which provides great performance. In
addition, the model you run on the edge isn’t very As the breadth of these functionalities shows,
large – only approximately tens of megabytes – Video Indexer combines many Cognitive Services,
because you deploy only the model and API, like Speech to Text and Speaker Recognition.
not the training data. Cumulatively, these services provide powerful
capabilities that make content more discoverable,
accessible and valuable.
// T
ry it out: Create your own
Custom Vision project
You can upload media files to Video Indexer using
the Video Indexer portal or the API. Figure 4-2
Video Indexer
shows the results of an Azure Friday video that
was uploaded to the Video Indexer service.
The Video Indexer service analyses the video and
audio files you upload to it. This Cognitive Service
is also a part of the Media Analytics suite of Azure
Media Services. It provides a predefined machine
learning algorithm and you provide the data.
• Creates a transcript of the text in a video. You As shown in the figure, Video Indexer created a
can refine the transcript manually and train transcript of the audio in the video. The transcript
Video Indexer to recognise industry terms like can be edited and even translated into other
‘DevOps’. languages. You can also see that Video Indexer
recognised text on the slide behind the speakers
• Tracks faces and identifies who is in a video
and marked it as ‘OCR’. You can skip to that text by
and at what points. Video Indexer has the same
clicking it. Video Indexer provides this functionality
capability for audio, for which it recognises who
for individual applications by embedding the
is speaking and when.
Cognitive Insights widget.
• Recognises visual text in a video, like text on a
slide, and makes that part of the transcript. // T
ry it out: Upload your first
video to Video Indexer
May The Developer’s 58
2019 Guide to Azure
The Q&A Maker Cognitive Service offers an easy Bing Autosuggest provides search suggestions
way to create a conversational layer over existing while you type. This enables you to give your users
data, like the frequently asked questions (FAQ) a search experience similar to using Bing or Google,
pages, support websites and product manuals. in which search results are automated or completed.
QnA Maker helps you analyse and extract the
information and convert it into question-and- Provide the search text character by character to
answer pairings that can be easily managed. Bing Autosuggest, and it quickly returns search
Simply put, QnA Maker allows you to build apps suggestions in JSON format.
that can provide information to your users in a
conversational manner. For instance, when you input the query text
“What should I search for”, the service returns the
With QnA Maker, it’s possible to create and manage following JSON (see page 59 for larger figure):
knowledge bases using the easy-to-use QnA Maker
Portal or using REST APIs. We have simplified the
bot creation process by allowing you to easily create
a bot from your knowledge base – without the
need for any code or settings changes. See more
details here: Create a QnA bot. Of course, you can
also use QnA Maker to create a bot using the Azure
Bot Service and augment your QnA bot by adding
the Language Understanding Service. To add
personality, you can add chit-chat to your bot and
answer commonly asked small talk scenarios out of
the box.
You pay only for the hosting of QnA Maker, not for
how many times the resulting service gets queried This contains all the suggestions. The original search
by users. query is contained in the top of the results.
// T
ry it out: Create your QnA Maker
knowledge-based service // T
ry it out: Get an API key and
try out Bing Autosuggest for free
May The Developer’s 59
2019 Guide to Azure
{
“_type”: “Suggestions”,
“instrumentation”: null,
“queryContext”: {
“originalQuery”: “what should I search for”
},
“suggestionGroups”: [
{
“name”: “Web”,
“searchSuggestions”: [
{
“url”: “https://www.bing.com/search?q=what+should+i+search+for&FORM=USBAPI”,
“urlPingSuffix”: null,
“displayText”: “what should i search for”,
“query”: “what should i search for”,
“searchKind”: “WebSearch”
},
{
“url”: “https://www.bing.com/search?q=what+should+i+search+for+on+bing&
FORM=USBAPI”,
“urlPingSuffix”: null,
“displayText”: “what should i search for on bing”,
“query”: “what should i search for on bing”,
“searchKind”: “WebSearch”
},
{
“url”: “https://www.bing.com/search?q=what+should+i+search+for+on+the+internet&
FORM=USBAPI”,
“urlPingSuffix”: null,
“displayText”: “what should i search for on the internet”,
“query”: “what should i search for on the internet”,
“searchKind”: “WebSearch”
},
{
“url”: “https://www.bing.com/search?q=what+should+i+search+for+today&
FORM=USBAPI”,
“urlPingSuffix”: null,
“displayText”: “what should i search for today”,
“query”: “what should i search for today”,
“searchKind”: “WebSearch”
},
{
“url”: “https://www.bing.com/search?q=what+should+i+search+for+in+dna+raw+data&
FORM=USBAPI”,
“urlPingSuffix”: null,
“displayText”: “what should i search for in dna raw data”,
“query”: “what should i search for in dna raw data”,
“searchKind”: “WebSearch”
}
]
}
]
}
May The Developer’s 60
2019 Guide to Azure
Azure
Azure Bot Service makes it easy to create a bot
and provides the following support:
// T
ry it out: Get started with
chatbots using Azure Bot Service
May The Developer’s 61
2019 Guide to Azure
Learning Studio
Algorithm Match
Data (Deep learning, Model
Clustering...)
Figure 4-3
You can add intelligence to your applications with
services from Azure such as Cognitive Services. The machine learning process works as follows:
These are based on machine learning algorithms
that Microsoft created to use as a service. However, • Data contains patterns. You probably know
there are other ways to use machine learning about some of the patterns, like user ordering
in your applications. First, let’s talk about what habits. It’s also likely that there are many
machine learning is. patterns in data with which you’re unfamiliar.
The studio itself is a portal that you can use from Learning Studio, with the workflow to be executed
your web browser and that enables you to create to train a model as well as the categories of
algorithms using a drag-and-drop approach. predefined steps that can be used in the workflow.
In the studio, you can start from scratch or with one When you’ve built your experiments and used
of the many experiments that are in the gallery, them on your data to create a machine learning
including one for predicting length of stays in model, you can publish them as web services. When
hospitals and another for anomaly detection in real- your applications use the web services, they can
time data streams. Use these experiments as the send data to your model and receive your model’s
Machine Learning Studio, you can create whatever Azure services that can help create, train and run
algorithm you want, providing flexibility for a your algorithm. You can, for instance, create your
variety of scenarios, like predictive analytics, data algorithm in Jupyter Notebook, train it using Azure
recommendations and data classification. Databricks, and deploy it on a Kubernetes container
cluster in Azure Kubernetes Service.
With Azure Machine Learning service, you create
custom machine learning algorithms from scratch.
This is different from the Machine Learning // G
et started with Azure
Studio, where you visually create an algorithm by Machine Learning service
connecting predefined pieces of a machine learning by using the Azure portal
algorithm. Azure Machine Learning service fully
supports open-source technologies like Google
TensorFlow, PyTorch and scikit-learn.
tooling for AI
Using machine learning models locally on devices
(the intelligent edge) delivers a powerful advantage:
it enables you to use the local processing power
of the device without relying on an internet
connection or incurring the latency of a web service
Visual Studio Tools for AI call to get your results.
Visual Studio Tools for AI is a free Visual Studio Described earlier in the Cognitive Services section,
extension. Use it to access a range of AI services the Custom Vision service already supports running
and frameworks, including the Microsoft Cognitive on the edge. You can expect more services to run on
Toolkit (CNTK), TensorFlow, Keras and Caffe2. the edge in the future.
Visual Studio Tools for AI allows you to create To run machine learning models on the edge, you
machine learning algorithms similarly to Azure need tooling to help you deploy the models and
Machine Learning Studio. You can use languages web services. The AI Toolkit for Azure IoT Edge
like Python, C, C++ and C# or leverage one of the helps with this tooling by enabling you to package
many samples in the machine learning experiments machine learning models in Azure IoT Edge–
gallery. compatible Docker containers and to expose those
models as REST APIs.
With Visual Studio Tools for AI, you can create
machine learning elements from Visual Studio The AI Toolkit for Azure IoT Edge contains examples
and take advantage of the power of Visual Studio for getting started and is fully open source and
to debug machine learning algorithms and train available on GitHub.
machine learning models. From Visual Studio,
you can create training jobs that can scale out
to many VMs in Azure. You can also monitor
training performance and then generate a web
service to use the machine learning model in your
applications. You can do all this without ever leaving
Visual Studio.
// T
ry it out: Download the Visual
Studio Tools for AI extension
May The Developer’s 65
2019 Guide to Azure
AI and
For example, people entering a hospital often have
difficulty getting to where they need to go. With
mixed reality
Azure Spatial Anchors, the hospital can create
a mobile app that shows digital information in
the physical hospital to guide people to various
locations. Within the app on their iOS device,
people can use the directional arrows on the
Your applications are no longer limited to a 2D hospital’s physical information boards to get to their
environment. The world is now your app canvas, destinations.
backed by spatial intelligence from things like IoT
sensors, mixed reality and computer vision. With Another way Azure Spatial Anchors is being used
Azure mixed-reality services, you can bring data to is in a training application for nurses. Pearson
life in 3D when and where your users need it. Education has enabled nursing students and
professors to practice diagnosing and treating
Azure Spatial Anchors patients in 3D before the pressure of a real case.
Students and professors may use HoloLens devices
In the world of mixed reality, you can integrate or mobile phones and tablets running iOS or
digital information within the context of your Android.
physical environment, like a hologram of your
favourite game characters on your kitchen counter. Azure Spatial Anchors enables you to share digital
With Azure Spatial Anchors, you can place digital information and holograms that are positioned in
content in a physical location and share that with the physical world. It works with apps built on Unity,
users using your choice of devices and platforms. ARKit, ARCore and Universal Windows Platform
(UWP) and can be used with a HoloLens device,
iOS-based devices supporting ARKit and Android-
based devices supporting ARCore.
May The Developer’s 66
2019 Guide to Azure
With Azure Spatial Anchors, you can easily secure But this loss of detail sacrifices information needed
your spatial data and give users access through to make the right decision in many situations. With
Azure Active Directory. You can also integrate Azure Remote Rendering, 3D models are rendered
storage, AI, analytics and IoT services into your in the cloud and streamed to devices in real time –
spatial application. with no compromise on visual quality.
// G
et started by sharing Azure This enables you to keep the original quality of
Spatial Anchors across sessions the model and interact with the content on edge
and devices devices like headsets and mobile phones with every
detail intact.
Azure Remote Rendering
Using events
One way to solve this problem is to use a queue to
decouple the web application from the web service.
and messages in
The web application receives the order and writes
it in a message on a Service Bus queue. Then the
web application informs the user that the order is
// G
et started with Azure Service
Bus queues
// T
ry it out: Get started sending
messages to Azure Event Hubs
May The Developer’s 69
2019 Guide to Azure
Just like Event Hubs, Azure IoT Hub is built for Azure Event Grid offers a different type of
massive data ingestion. It’s specifically geared messaging – a fully managed publish and subscribe
toward handling the enormous volume of data service that hooks into almost every service in Azure
messages from devices on the Internet of Things, as well as into custom publishers and subscribers.
like smart thermostats and sensors in cars.
This is different from working with the Service Bus
It has many of the same properties as Event Hubs, queues and topics, for which you’d need to poll
like the ability to retain messages for up to seven the queue or topic for new messages. Event Grid
days and replay them. automatically pushes messages to subscribers,
making it a real-time, reactive event service.
What makes IoT Hub unique is that it can send
messages to devices. It has the ability to manage Services in and outside of Azure publish events
your complete IoT infrastructure – you can use it when a new blob is added, for example, or when
to register devices, report their state, manage them a new user is added to an Azure subscription.
by securing and restarting them and send data Azure Event Grid detects these events and makes
to them. them available to event handlers and services that
subscribe to the events, as shown in Figure 4-5.
// T
ry it out: Connect your device
to your IoT hub Event handlers can be Azure Functions or Azure
Logics Apps, which can then act on the data in the
event.
Blob Storage
Azure Functions
Resource Groups
Logic App
Azure Subscriptions
Azure Automation
Event Hubs
WebHooks
Custom Topics
Figure 4-5
May The Developer’s 70
2019 Guide to Azure
You can use Azure Event Grid if you want an email SignalR can update connected applications in
notification every time a user is added to or deleted real time over HTTP, without the need for the
from your mailing list in Mailchimp. Azure Event applications to poll for updates or submit new HTTP
Grid is used to activate an app in Azure Logic requests. This enables you to create seamless web
Apps and configured to listen to changes to the experiences that update information on the fly.
Mailchimp mailing list. Azure Event Grid then signals For example, an auction application might
Logic Apps to send an email containing the name use SignalR to refresh the latest bid as soon as
of a user who has been added or deleted and the it happens, without completely refreshing the
action that was performed. page or constantly polling for information.
// T
ry it out: Monitor virtual Hosting a SignalR server yourself is not a trivial
machine changes with Azure task and it can be difficult to scale and secure
Event Grid and Logic Apps properly. When you use the fully managed
Azure SignalR Service, set-up is easy and security,
availability, performance and scalability are all
managed for you.
// T
ry it out: Create a chat room
with SignalR
May The Developer’s 71
2019 Guide to Azure
Azure provides myriad options to perform You can learn more about using Azure AI services
messaging and to decouple applications. Which one in your application in this free eBook:
should you use, and when? Table 4-4 summarises
the differences to help you choose.
// A
Developer’s Guide
to Building AI Apps
Table 4-4
Service*
SignalR
Event Grid*
Event Hubs*
IoT Hub*
Topics*
queues*
Service Bus
storage*
Azure Queue
Event ingestion ● ● ●
Device management ●
Messaging ● ● ● ● ● ● ●
Multiple consumers ● ● ● ● ●
Multiple senders ● ● ● ● ● ● ●
Use for decoupling ● ● ● ● ●
Use for publish/subscribe ● ●
* Services with an asterisk have a free tier that you can use to get started at no cost.
February Lorem
May ipsum dolor sit
Theamet,
Developer’s
consectetur 72
2018 adipiscing
2019 elit Guide to Azure
05 /
Mus ma dolor Duntiaspel is vel estotatem qui qui sitatio
nsedit, ea sere volor molupta dolut officto
Connect
dolum earum minctur simillab is arum quatinverro
te destibus, tem adis eum rehenia si
omnimusam veni nossita.
your
business
with IoT
May The Developer’s 73
2019 Guide to Azure
for instance, to route incoming messages using IoT to interact with IoT Hub. Importantly, the company
Hub message routing that offers simplicity, reliability now has control over the security of its devices and
and scalability without the complexity of building can detect their status and reset them as needed.
custom routing solutions. In addition, the company routes the data from its
GPS dongles through Azure Stream Analytics, so
Another option for integrating IoT events into Azure only the data of GPS changes is kept. This reduces
services or business applications is to use Azure the data burden because the dongles send their
Event Grid, a fully managed event routing solution location every second.
that uses a publish-subscribe model. IoT Hub and
Event Grid work together to integrate IoT Hub Using Azure IoT Hub enabled this company to scale
events into Azure and non-Azure services in near- and mature its business by providing first-class
real time. security and device management. It also opened
new opportunities to do more with devices than the
You can also create bi-directional communication company ever thought possible.
tunnels using device streams. Azure IoT Hub device
streams facilitate the creation of secure bidirectional
TCP tunnels for a variety of cloud-to-device Azure IoT Central
communication scenarios.
Azure IoT Central is a hosted IoT solutions platform
Example: Azure IoT Hub that enables you to create rich IoT applications just
by navigating through wizards.
business. Previously, the company tracked its assets configuration – IoT Central does all that for you,
by using custom code on a native phone app, which provisioning and configuring everything you need,
called a custom web service and by polling GPS including Azure IoT Hub.
to provision new assets with new devices, and the the solution from scratch, but without the need for
company needed to enrol a new customer that had years of programming experience. If you do want
more than 2,000 assets. more control over certain areas, you can always go
deeper and tweak the solution to your needs.
Azure IoT
solution
accelerators
Azure IoT solution accelerators are a great place to
start building your IoT solution. Figure 5-1
• The IoT Edge runtime runs on each IoT Edge Once you start using Azure IoT Edge, you’ll be able
device and manages the modules deployed to to create fast applications that run machine learning
Digital Twins
the physical environment in which your IoT devices
reside with Azure Digital Twins. This service enables
you to create a graph of data that includes places,
people and things – for instance, an office building
that contains a room with people and sensors.
In the world of IoT, you might work with many IoT
devices and sensors that function in connection to With Azure Digital Twins, you can provide context to
people and objects. To really understand the data data from various sources and relate them to each
that IoT devices capture, you need to understand other – for instance, the temperature and humidity
the physical environment in which the devices data from sensors in the same room. This allows you
operate. to query data in the context of a space rather than
from individual sensors.
For instance, if you have a temperature sensor, the
temperature data by itself doesn’t tell you that Azure Digital Twins also lets you to manage
much. However, when you know which room the permissions to data and devices in the context of
sensor is in, how large the room is, which other the physical world. You can use Azure AD to specify
devices are in the room and what data they capture that certain users are able to access data only from
and how many people are in the room and how a certain physical location.
// G
et started by finding
available rooms using
Azure Digital Twins.
May The Developer’s 79
2019 Guide to Azure
Azure Sphere
However, it’s complex and challenging to secure
devices with embedded microcontrollers, as
evidenced by the many security incidents with
connected devices over the last years.
Learn more
Azure IoT solutions are easy to use and there are
many related resources, including:
about Azure IoT • Azure IoT School: This free online academy
provides comprehensive training for Azure IoT,
with a variety of courses ranging from beginner
to advanced.
and when?
Learn more about using Azure for your IoT solution
in the following free eBooks:
Table 5-2
Azure IoT
Azure IoT Azure IoT
Azure IoT Hub Solution
Central Edge
accelerators
All services have a free tier you can use to get started.
*Azure IoT Hub is required to manage Azure IoT Edge deployments and devices.
February Lorem
May ipsum dolor sit
Theamet,
Developer’s
consectetur 82
2018 adipiscing
2019 elit Guide to Azure
06 /
Mus ma dolor Duntiaspel is vel estotatem qui qui sitatio
nsedit, ea sere volor molupta dolut officto
Where
dolum earum minctur simillab is arum quatinverro
te destibus, tem adis eum rehenia si
omnimusam veni nossita.
and how
to deploy
your Azure
services
May The Developer’s 83
2019 Guide to Azure
Infrastructure
It’s easy to create Azure Resource Manager
templates in Visual Studio and Visual Studio Code
as Code
using Azure Resource Group project templates.
You can also generate Azure Resource Manager
templates from the Azure portal by clicking the
Automation Script button, which is available on
the menu bar of every resource in the Azure portal.
Infrastructure as Code (IaC) captures environment This creates the Azure Resource Manager template
definitions as declarative code, such as JSON for the given resource and even generates code
documents, for automated provisioning and for building the resource using the Azure CLI,
configuration. All Azure services introduced in this PowerShell, .NET and others.
guide are based on Azure Resource Manager, which
you can use to document your environment as IaC After you have an Azure Resource Manager
thanks to Azure Resource Manager templates. template, you can deploy it to Azure by using
These templates are JSON files that describe what PowerShell, the Azure CLI or Visual Studio. Or
you want to deploy and what the parameters are. you can automate its deployment in a continuous
deployment (CD) pipeline using Azure DevOps.
Azure Blueprints
It’s easy to use Azure Resource Manager templates,
resource groups, user identities and access rights
and policies to design and create a complete
infrastructure. But how do you keep all of these
things together? And how do you keep track of
which environments each piece of infrastructure has
been deployed to and which version of the artefact
is deployed now?
// G
et started by defining and
assigning an Azure Blueprint
in the Azure portal.
May The Developer’s 86
2019 Guide to Azure
Containers in Azure
‘Containerisation’ is one of those technology exact same container configuration, so you know
buzzwords flying around in the news. But containers that the infrastructure is the same for everybody
are more than just buzz – they’re actually very as it is in production. With containers, the age-
useful for running your applications. A container old developer’s fallback statement – ‘works on
is basically a lightweight VM that starts and stops my machine’ – now means that it will also work
much faster than a traditional VM and is therefore in production.
more useful for development, testing and running
applications in production. There are many technologies for running
containers, including Docker. Azure can run and
The major benefit of containers is that an individual manage containers with Azure Container Instances
container is always the same. You run a container and Azure Kubernetes Service. You can also run
locally when you develop your app, and then use containers in Web App for Containers and in
the same container configuration in the cloud Azure Batch. Table 6-1 shows which service you
and everywhere else. Your entire team uses the might choose for various scenarios when using
containers.
Table 6-1
Azure Stack
You can run things like Azure App Service and
Virtual Machines on Azure Stack. Everything is
exactly the same as in the public cloud, except
that you’re running it on-premises. If you decide
to move to the public cloud, you can simply push
If you need your applications and data to remain
services from Azure Stack to Azure.
on-premises, but still want to benefit from the
power that Azure has to offer, Azure Stack is the
Example: Azure Stack
product for you. Unique in the industry, Azure Stack
is an extension of Azure that you host in your own
To help with cruise tasks, a company that offers
environment. Essentially, it’s Azure in a box.
luxury cruise ship holidays has built various
software, including a cabin management
You use Azure Stack in the same way you use Azure,
application and a passenger management
with the same Azure portal experience and the
application. The entire cruise ship relies on these
same APIs which you can use with the Azure CLI,
applications. In the past, the applications were
PowerShell or your favourite IDE.
running on servers carried aboard the cruise ships.
The company was forced to do it this way because
the cruise ships didn't have a connection to the
internet for the whole journey.
Where to deploy,
and when?
If you want to deploy IaaS-based services If you want to deploy PaaS-based services (where
(in which you control the OS), consider these you have less control, but the platform does the
options: heavy lifting), consider these options:
• On-premises or anywhere else (like your local • On-premises or anywhere else (like your local
PC or another cloud), you can use: PC or another cloud), you can use:
• Azure Stack (where you deploy services • Azure Stack (as you can deploy PaaS
like VMs) services like App Service in Azure Stack)
• Any of the Azure container services (as • In the public Azure cloud, you can use:
containers can run anywhere)
• Any Azure PaaS service that
• In the public Azure cloud, you can use: you script as a Resource
Manager template
• Containers (as containers also run in any of
the Azure container services)
Further reading
// M
aking the Most of the
Cloud Everywhere
// Effective DevOps
07 /
Mus ma dolor Duntiaspel is vel estotatem qui qui sitatio
nsedit, ea sere volor molupta dolut officto
Share your
dolum earum minctur simillab is arum quatinverro
te destibus, tem adis eum rehenia si
omnimusam veni nossita.
code, track
work and
ship software
May The Developer’s 90
2019 Guide to Azure
How can
• Azure Pipelines
Use Azure Pipelines to create build and
Azure help you
release pipelines that automate builds and
deployments.
collaborate better
code quality with manual and exploratory
testing services for your apps.
apps faster?
(like npm, NuGet and Maven packages) across
your organisation.
• Azure Boards
Use Azure Boards to plan, track and discuss
work across teams.
• Azure Repos
Use Azure Repos to collaborate on code
development with free Git public and private
repositories, pull requests and code review.
May The Developer’s 91
2019 Guide to Azure
Azure Boards
The whole planning system is optimised for working
in an agile way. It even includes Kanban boards for
managing your work (Figure 7-1).
Azure Repos Azure Repos uses standard Git. This means that you
can use it with any Git tool and IDE, including Visual
Studio and Visual Studio Code as well as Git for
Windows, Mac, Eclipse and IntelliJ.
// G
et started by learning
how to code with Git
May The Developer’s 93
2019 Guide to Azure
Team Foundation Version Control With TFVC on Azure Repos, everyone can download
the versions of code branches you create on the
Team Foundation Version Control (TFVC) is a server. Azure Repos also provides a rich toolset that
centralised version control system that ensures allows you to attach work items to code changes.
one source of truth is always kept on the server. It’s also possible to request and perform code
Developers usually have only one version of each reviews, so your team can discuss changes and
file on their machine, which makes it more difficult recommend updates before they’re merged into
to work offline. the main branch.
Azure Pipelines
integration tools like Jenkins or Spinnaker, you can
easily bring your existing builds and pipelines to
Azure and take advantage of dynamic agent plug-
ins to reduce infrastructure requirements and costs.
Azure Pipelines works very well with Azure services Build pipeline: The build pipeline (or CI pipeline) in
to deploy your application in an Azure web app, Figure 7-2 shows a list of tasks that will be executed
for instance. It also works with any service that when this pipeline runs. The pipeline is configured
runs in any other environment, such as Google to run as soon as new changes are committed to
Cloud, Amazon or even on-premises in your own Azure Repos. It will take the code in Azure Repos
datacentre. If you’re already using continuous (which is a Node.js app), build a Docker container
May The Developer’s 95
2019 Guide to Azure
Azure Artifacts
Follow these simple steps to use Azure Artifacts:
08 /
Mus ma dolor Duntiaspel is vel estotatem qui qui sitatio
nsedit, ea sere volor molupta dolut officto
Azure
dolum earum minctur simillab is arum quatinverro
te destibus, tem adis eum rehenia si
omnimusam veni nossita.
in action
May The Developer’s 99
2019 Guide to Azure
Walk-through #1:
The Application Insights service tiles show
information like active alerts, live data coming in,
Figure 8-2
Tiles in the Azure portal
When you find the service you want from the search down. You can also select which ones you want to
results, as shown in Figure 8-4, a wizard takes you see by expanding the favourites menu and selecting
through configuring and deploying it. the star symbol next to those categories.
Understanding blades
Let’s use the Azure portal to create a new VM. Once 5. Choose a name for the VM.
we’ve done so, we’ll shut it down and remove it so
that you don’t continue to pay for it. 6. Choose the disk type. SSD provides a faster VM
but is more expensive. For this walk-through,
7. Type a username.
The VM will be deployed in a resource group, a
logical container that holds resources. All Azure 8. Select Password for the authentication type.
resources reside inside resource groups. You can
9. Type a password and confirm.
manage the security of a resource group as well
10. In the Resource Group box, type a new name.
May The Developer’s 102
2019 Guide to Azure
11. Choose the location of the VM, and then 14. Review the summary, agree to the terms and
click OK. then click Create.
12. Choose the VM size. There are many sizing It usually takes just a few minutes for the VM to
options for VMs. VM performance determines be deployed. When you navigate to the VM in the
the cost. Use the wizard to select how many Azure portal, you can configure it further and log in
cores and how much memory you want, and using Remote Desktop Protocol (RDP).
choose options based on that. In addition, there
are other features that come with size options,
such as:
• The ability to perform load balancing. When you’re finished with the VM, shut it down
and remove it by deleting the resource group
• The graphics card installed in the VM.
that we created when we generated the VM. This
This is useful if you need to execute
contains the VM and all other resources that are
substantial graphics rendering or a heavy
automatically created. Once the resource group is
computational workload.
deleted, you no longer pay for any of the resources
13. After you select the size, you can configure that you’ve used in this walk-through.
additional settings like the virtual network,
IP address and extensions on the machine.
For now, leave everything as is and select OK.
May The Developer’s 103
2019 Guide to Azure
Developing a web To host the .NET Core application, we’ll create a new
web app in the Azure portal.
on Azure Service.
Figure 8-8
May The Developer’s 104
2019 Guide to Azure
You can run as many App Services on an App 7. Select a pricing tier. For development and test
Service Plan as you want, but note that you need to purposes, the Basic tier is sufficient.
share resources among all the App Services.
8. Click Create. The database will now be created.
To host the database, we’ll create a SQL database. 9. Navigate to the SQL database and click Show
This works the same as a local SQL Server database Database Connection String.
and now runs fully managed in Azure.
10. Make note of the connection string because
1. In the Azure portal, click Create A New Service. you’ll need it later in this tutorial.
2. Search for SQL Database and click it to Running the .NET Core app locally
open the SQL Database blade. Click Create.
The Create SQL Database blade opens. Let’s run the app locally before we run it in Azure.
The app can run locally because by default, it uses
3. Type a database name.
a SQLite database, which is a self-contained SQL
4. Select the resource group that you created for database engine.
the web app.
1. Open a command prompt and navigate to a
5. Leave the source as Blank database.
directory you want to use as your source code
6. Click Server to create a new SQL database directory for this project.
server.
2. Run the following commands to get the source
a. Type a name for the server. code and navigate to the project folder:
to the server.
dotnet run
May The Developer’s 105
2019 Guide to Azure
4. The app should now be running, and the URL to Connecting the local web app to the
the app (such as http://localhost:5000) should database running in Azure
be in the output in the command window
You now have a working application running
5. Navigate to that URL in a browser. This will load
locally. Before we deploy it to Azure, we’ll change
the application, which will look like that shown
the source code so that it can connect to the SQL
in Figure 8-9. Now you can create new to-do
database.
items by selecting the Create New link.
6. Close the application by closing the command 1. In your local source code repository, find the
window or pressing Ctrl+C. Startup.cs file and locate the following code:
servicesAddDbContext<MyDatabaseContext>
(options => options.UseSqlite
(“Data Source=localdatabase.db”));
if(Environment.
GetEnvironmentVariable(“ASPNETCORE_
ENVIRONMENT”) == “Production”)
services.
AddDbContext<MyDatabaseContext>(options =>
Figure 8-9
options.UseSqlServer(Configuration.
GetConnectionString(“MyDbConnection”)));
else
services.
AddDbContext<MyDatabaseContext>(options =>
options.UseSqlite(“Data
Source=localdatabase.db”));
This code looks at the environment in which it’s 6. Create a new connection string named
running and changes its database connection MyDbConnection. The value should be
based on that information. When running in the the connection string to the SQL database
production environment (Azure, in this case), (including username and password) you saved
the code will get the connection string for the earlier when you created the database.
database from the MyDbConnection variable,
7. Click Save. The application settings in the
which we’ll configure in Azure.
Azure portal should look like those shown
in Figure 8-10.
The code also runs the Database.Migrate()
method, which executes the Entity Framework
Core migrations that we previously ran
manually.
4. In the Azure portal, navigate to the web app different from your Azure subscription account. You
that we created earlier. need to configure this deployment user only once.
2. The Azure Cloud Shell enables you to use 6. Once the remote target is added to the Git
the Azure CLI in the cloud and manages repository, you can push your code to it by
authentication. When the Cloud Shell is fully running the following command. You’ll need
loaded, run the following command to create to enter credentials to be able to push code to
the deployment user. Replace the <username> Azure. Use the username and password you
and <password> values with ones you create. used to create the deployment user.
Make note of the username and password
because you’ll need them later. git push azure master
az webapp deployment user set --user-name Pushing the source code to Azure might take
<username> --password <password>
a few minutes the first time. Once complete,
navigate to the URL of your Azure web app,
3. The command results in a JSON output. If you which will look like this: http://<app_ name>.
receive a ‘Conflict’. Details: 409 error message, azurewebsites.net
change the username. If you receive a ‘Bad
7. Add some to-do items in the application to test
Request’. Details: 400 error message, create a
its connection to the database.
stronger password.
Now you have a working application running in
Now we’ll push the source code from the local
Azure.
Git repository to the Azure web app.
Walk-through #3:
We’ll set this up using the Logic Apps feature of
Microsoft Azure App Service and the Language
Extending
Understanding Intelligent Service (LUIS), as
follows:
applications with • The .NET Core app writes the to-do item in the
SQL database.
Logic Apps and • The logic app is triggered by every new row
created in the database.
Cognitive Services • The logic app takes the to-do item text and
passes it to the Language Understanding
service.
A powerful feature of our application is its ability
• The Language Understanding service analyses
to analyse the content of to-do items and then
the text and creates a calendar item in your
automatically create calendar appointments for
Office 365 calendar if the text contains a date
tasks that include a specific date.
and time.
For example, if a user creates a to-do item with We don’t have to change our application to add
the text “family dinner next Friday at 7:00 PM”, this functionality. Logic Apps and Cognitive Services
the application will create a calendar item for are additional services that simply analyse the data
that specific Friday at 7:00 PM with the subject that’s already there.
“family dinner”.
Let’s get started.
May The Developer’s 109
2019 Guide to Azure
5. Create a new resource group called 7. Type a name like ‘Add to-do calendar item’,
Now you can enter utterances. These are sample 15. The model is now published to production.
texts that represent the intent we want to detect. Scroll down to Resources and Keys and make
note of the key string you’ll find there because
9. Enter “family dinner next Friday at 7 PM” to
we’ll need it for our logic app.
represent the intent of adding a to-do item to
the calendar.
Creating the logic app
10. Because we’ve already added two entities,
The logic app we create will be triggered by the
the text in the utterance is analysed and
new rows of to-do items written in SQL Database.
recognised as these entities, as shown in Figure
It will then take the value of each to-do item and
8-11. The text “family dinner” is recognised as
send it to the Language Understanding service to
a keyPhrase. The text “next Friday at 7 PM” is
be analysed. If the Language Understanding service
recognised as datetimev2.
finds a date in the item, it will create a new calendar
11. Let’s use this model to train the service and event in your Office 365 account.
publish it. Select Train in the upper-right corner
Let’s create the logic app:
of the screen.
1. In the Azure portal, click Create A New Service.
keyPhrase datetimev2
2. Search for Logic App and click it in the search
Figure 8-11 results to open the Logic App blade. Click
Create. The Create Logic App blade opens.
• This performs machine learning training
and builds a machine learning model based 3. Type a name.
on what we’ve just entered.
4. Select the resource group that you created for
• To test if the service works as expected, the Language Understanding service.
type “family dinner next Friday at 7 PM” in
5. Choose a location.
the Test window next to the Train button.
6. Click Create.
12. Now that we have a working service, we need
to publish this model to production. Click 7. When the logic app is created, you’ll see a
Publish in the menu (next to the Train button) quick-start page that asks if you want to start
to bring up the Publish page. the logic app from a template (Figure 8-12).
Choose Blank Logic App.
13. Leave the slot as Production.
We now need to create a trigger for the logic app. Now the logic app will be triggered every time
2. Select the When an item is created task. Next, we’ll add another action for the logic app.
This will ask for the connection to the
SQL database (Figure 8-13). 1. Click the plus sign under the SQL task, and then
select Add an action to add the next action
(Figure 8-14).
Figure 8-13
3. Type a name for the connection. 16. Select the App ID as we did earlier.
4. Paste in the connection key you saved when we 17. Select builtin.datetimev2 for the desired entity.
published the Language Understanding model.
18. Select the LUIS Prediction object for the
5. Click Create. luisPredictionObject field.
6. Select the App ID that you created in the 19. Below this action, add another one for
Language Understanding portal. Get entity by type.
7. Select the description from the SQL task as the 20. Select the App ID.
input for the Utterance field.
21. Select builtin.keyPhrase for the desired entity.
8. Select the Add to-do calendar item for the
22. Select the LUIS Prediction object for the
desired intent. This will output whether the
luisPredictionObject field.
task contains a date.
23. Create a new action while still in the if true
9. Click the plus sign, and then click Add a
box. Search for Office 365 and then select the
condition. We’ll test whether the text contains
Create Event V2 action. This can create an
a date by checking if the desired intent was
event in your Office 365 calendar.
true. If the text does contain a date, we’ll create
a calendar event. If it doesn’t, we won’t do 24. Note that this requires a connection to
anything. Office 365. Click add new connection and log
in with your Office 365 credentials. The logic
10. In the condition, select the Is Desired Intent
app will keep your connection in your Azure
value from the Language Understanding task
subscription.
for the value.
25. Select the calendar to create the event.
11. Leave the is equal to statement as is.
26. In the End Time and Start Time fields, select
12. Add true in the value textbox.
the Entity Value from the action where you
13. The condition appears in both the if true and filter the datetimev2 entity.
if false boxes. In the if true box, create a new
27. In the Subject field, select the Entity Value from
action.
the action where you filter the keyPhrase entity.
14. Search for LUIS as we did earlier.
28. Save the logic app flow. The if yes box should
15. Select the Get entity by type action. This is a look similar to that shown in Figure 8-15.
Language Understanding action that extracts
29. Navigate to the to-do app URL, which is the
an entity based on its type from the Language
URL of your web app from the previous walk-
Understanding results.
through.
May The Developer’s 113
2019 Guide to Azure
Walk-through
#4: Ready for
production Figure 8-16
4. In Choose Source, select GitHub. There are deployment slots for staging, load testing
and production, which is always the original App
5. In the Authorisation section, authorise Azure to
Service – in our example, the .NET Core web app. In
use GitHub by selecting Authorise and granting
fact, you can have as many deployment slots as you
permission.
want without incurring additional costs.
6. In the Choose Project section, choose the
The deployment slots all run in the same App
GitHub repository that you just created.
Service Plan, which is what you pay for. Keep in
7. Leave the branch set to master. mind that having additional deployment slots in an
App Service Plan will consume resources like CPU
8. Click OK.
and memory.
9. Return to the Deployment Options menu.
You create new deployment slots from the
You can now see that GitHub is connected.
Deployment Slots menu item in the web app.
From this point, whenever you push a new
You need to run the web app in the standard or
version of source code to GitHub, it will be built
premium pricing tier because the free plan doesn’t
and deployed to the web app automatically.
come with any deployment slots.
This is shown in Figure 8-17, which illustrates
the Deployment Options blade. You can also
force this process by clicking Sync.
May The Developer’s 116
2019 Guide to Azure
In each deployment slot you create, you can 8. Disconnect the CD connection in the
configure the deployment options as we did earlier original .NET Core web app. This way,
to deploy code automatically. You can even work when you push new code, it’s delivered
on different source code branches for different only into the staging slot.
environments and automatically deploy specific
9. In the .NET Core app, change some text in the
branches to specific deployment slots.
Index.cshtml file in the Views/Home folder.
Additionally, you can test your final version in
10. Commit it to Git and push it to GitHub, just like
a deployment slot and then swap it with the
when you deployed the .NET Core app.
version in the production slot. This warms up
the application before it swaps, resulting in a The new version is now in the staging slot and
deployment with no downtime. not in the original web app, which we call the
production slot. You can verify this by navigating to
Let’s see how to create a deployment
the URL of the .NET Core web app and to the URL of
slot and swap to it.
the staging slot, which you can find in the Overview
1. In the Azure portal, go to the web app that blade of the slot.
hosts the .NET Core app.
Now let’s put the new version into production.
2. On the menu bar, click Deployment Slots.
1. In the Azure portal, go to the .NET
The Deployment Slots blade opens.
Core web app.
3. Click the plus sign to create a new
2. On the menu bar, select Deployment Slots to
deployment slot.
open the Deployment Slots blade.
4. Type a name for the slot, for example, “staging”.
3. Click Swap to open the Swap blade. Leave all
5. Choose the .NET Core web app as the settings as they are.
configuration source. This copies the
4. Click OK to initiate the swap.
application settings to the new slot.
Once the swap is complete, the new version of the
6. Click OK to create the slot, which is similar to
.NET Core web app is in production. You can test it
the original web app.
by navigating to the URL of the Node.js web app.
7. Set up CD for the slot, just as you did for the Using deployment slots in this way is beneficial
web app. because you can test the new version before it goes
into production and then deploy it to production
with no downtime.
May The Developer’s 117
2019 Guide to Azure
Figure 8-18
4. Type a name and select a location for the
Application Insights instance.
09 /
Mus ma dolor Duntiaspel is vel estotatem qui qui sitatio
nsedit, ea sere volor molupta dolut officto
Summary
In this guide, we introduced the
dolum earum minctur simillab is arum quatinverro
power that Azure can bring to your
te destibus, tem adis eum rehenia si
applications. Using Azure, you can
omnimusam veni nossita.
do incredible things with your apps –
and
employ facial and speech recognition,
manage your IoT devices in the cloud,
scale as much as you want – and pay
resources
only for what you use.
Keep learning
with Azure
With your Azure free account, you get all of this –
and you won’t be charged until you choose to
upgrade:
http://www.azure.com/free
May The Developer’s 122
2019 Guide to Azure
About the
authors
Michael and Barry are passionate about Azure and Michael Crump works at Barry Luijbregts is an
Microsoft on the Azure independent software
encourage you to reach out to them on Twitter for platform and is a coder, architect and developer with
questions regarding this book. blogger and international a passion for the cloud and
speaker on various cloud authors courses for Pluralsight.
development topics. He’s
passionate about helping You can reach Barry on Twitter
developers understand the @AzureBarry and through
benefits of the cloud in a no- his website at https://www.
nonsense way. azurebarry.com/.
Microsoft Press books are available through booksellers and distributors worldwide. If you
need support related to this book, email Microsoft Press Support at mspinput@microsoft.
com. Please tell us what you think of this book by taking this survey.
This book is provided ‘as is’ and expresses the author’s views and opinions. The views,
opinions and information expressed in this book, including URL and other Internet website
references, may change without notice. Some examples depicted herein are provided for
illustration only and are fictitious. No real association or connection is intended or should
be inferred.