(upbeat music)
Welcome back to Azure AI Essentials
Today, we're going to take a look
at how you can use Azure Cognitive Services in containers.
These containers allow you to use the same APIs
that are available in Azure on-premises
to give you the flexibility
of bringing cognitive services closer to your data
for compliance,
security,
or other operational reasons.
Let's dive right in.
So what is a container?
A container is a standard package of software
that bundles an application's code together
with the related configuration files and libraries
and with the dependencies required
for the app to run.
This allows developers and IT pros
to deploy applications seamlessly across environments.
You might be thinking that this sounds similar
to using a virtual machine.
So how is this beneficial?
Containers are different from virtual machines
in the sense that they can be isolated from each other
and their underlying operating system.
Everything you need to run an application
is contained in the container,
removing dependencies on the host environment.
This makes your application more portable
and efficient.
Essentially, we've taken the same exact
machine learning models,
code repositories and model code
for cognitive services web APIs
and packaged it in a container image.
These container images can run on-premises
such as in data centers or Azure Stack Hub.
Or they can run on orchestrators
like Kubernetes and Red Hat OpenShift.
They can even run on Edge devices
like our recently announced Azure Percept devices.
With containers, you can process your data anywhere
and still have access to Azure Cognitive Services APIs,
giving you the added benefit of flexible deployment.
Currently, Azure Cognitive Services provides
several Docker containers,
such as decision containers for anomaly detector,
language containers for text analytics,
vision containers for computer vision
and form recognizer,
and many more.
These capabilities offer increased flexibility
to our customers to apply AI
to their specific business needs and environments.
Take for example, TIBCO.
A software provider that helps its customers
embark on their digital transformation journeys.
TIBCO uses Azure Cognitive Services and containers
as an underlying technology
for its anomaly detection solutions
to detect and analyze sudden changes in data patterns.
TIBCO's anomaly detection solution
discovers root causes
and provides suggested actions
with a ready-made solution
that eliminates development time
for their end customers.
As a developer,
you may think that a sophisticated solution like this
would take months to develop,
especially if you're dealing a power plant
or manufacturing facility with limited connectivity.
But it's actually quite simple
to get started with.
Let's take a look at how you
as a developer
would deploy the anomaly detector container.
Before you begin,
you'll need the Docker engine installed
on your computer
and configured to allow containers
to connect with Azure.
The first step is to create
an anomaly detector resource.
You can search in the Azure marketplace to find it,
and then create a new resource group.
Once you've reviewed
and created your anomaly detector resource,
you can gather your API endpoint and key.
Both of these will be used
when you deploy the container.
At this point,
you can go to Docker Hub
to pull the anomaly detector container image.
Make sure you have Docker running on your desktop.
Then open up the command window
and provide the Docker pull.
This will enable you to pull the latest Docker image
of anomaly detector.
While that's loading,
let's grab the Docker run command
to spin up the Docker container instance.
You can find this for each
of our cognitive services containers online,
along with a recipe for specific container instances.
Copy the Docker run command
and replace the API end point and key portions
with your real end point and key
you previously gathered from the anomaly detector resource.
You can see that it's listening on port 5000.
We can now make an API call
against this container.
A great way to verify
if the container is functioning properly
is to navigate to the HTTP endpoint
and see that it's up and running.
You can also view the swagger file
that describes the APIs and capabilities.
Now, anomaly detector
and just time series data of all types
and allows you to select
the best fitting detection model for your data.
You can adjust the sensitivity
of the backend API
to adjust filtering on the data points collected.
And you can pinpoint where specific anomalies occur.
And just like that,
your container has been created
and is ready to use as you would
a typical web API anomaly detector service.
In general,
the use of cognitive services in containers
follows a generic workflow
of creating the resource in Azure,
getting the endpoint,
retrieving the API key,
finding the container for the service,
deploying the container,
and using the container endpoint
as you would use the API resource.
In fact, the use of cognitive services and containers
is exactly the same
as if you would use them in Azure.
Now, if you want to perform these steps
without having to manually navigate
the Azure portal each time,
here's a pro tip for you.
Use the Azure Command Line Interface or CLI
in combination with Azure container instances.
The Azure Command Line Interface
is a set of commands used
to create and manage Azure resources
and is available across Azure services.
It's designed to get you working quickly with Azure
with an emphasis on automation.
So how do you actually use the Azure CLI.
Let's walk through an example.
This time let's run a cognitive service speech container
and an Azure container instance
and use the REST API to convert text to speech.
To begin, make sure you have
the Azure command line interface installed.
To create a resource group in Azure CLI,
you need to specify two parameters.
The name of the group
and the location of where the group is deployed.
Next, we're going to specify
that we want to create the speech cognitive service.
After the speech service has successfully deployed,
we can extract the endpoint URL
and the API key.
Now, I mentioned that we'd use Azure CLI
in combination with Azure container instances.
And here's where that comes into play.
Azure container instances offers the simplest way
to run a container in Azure without having to adopt
a higher level service.
It's also a great solution for any scenario
that can operate in isolated containers
including simple applications,
task automation,
and build jobs.
With a single prompt in the Azure CLI,
you can deploy a container
and make it accessible by everyone.
To create an Azure container instance,
you need to feed it a few parameters.
If you want your container instance
to be accessible from the internet,
you'll need to specify the parameter,
DNS,
name, label.
Copy and paste the billing endpoint and API key
and hit Enter.
The deployment of our Azure cognitive service is underway
and will only take a few minutes.
To validate if the container is running,
you can use the same approach as before
by using a browser and navigating
to the containers homepage.
Retrieve the URL using the CLI
and navigate to the URL on port 5000.
You can now see that our speech container
is up and running.
To test our service,
we'll need to create a post request.
I'm going to do this using a program
called Postman.
In the request,
we can specify the voice we want
as well as the text we want
to convert to speech.
Let's try it out.
- [Automation] Hello world.
- And there you have it.
So now that we've explored what containers are
and how to use them with Azure Cognitive Services,
you've been armed with the flexibility
to cater to your own applications.
Flexible deployment of Azure AI services
enables you to continue developing
mission critical solutions
with the most mission critical tools.
For more information
on flexible deployment options
of Azure Cognitive Services,
please visit our online documentation.
Thanks for tuning in to another episode
of Azure AI Essentials
We're excited to see what you create
with the endless options
of flexible deployment available to you.
(upbeat music)