Exercise - Set up and use a container

Completed

Exercise - Create a language resource

In this exercise, you'll create an Azure subscription and a language resource, and then you'll copy the key and endpoint of the language resource that you created.

Task - Create an Azure subscription and a resource group

If you already have an Azure subscription, skip to the next task.

  1. Go to Discover AI services with an Azure free account and Sign in.

  2. Select Start free.

  3. Fill out the form and then select Next.

  4. Provide payment information and then select Sign up.

  5. After creating an Azure subscription, select Resource groups.

    Screenshot of the Azure services section, showing the Resource groups button.

  6. Select Create.

    Screenshot showing the create new resource button in the Resource groups area.

  7. Select the subscription that you created, enter DemoLanguageGroup for the Resource group, select your Region, and then select Review + create.

    Screenshot showing the Create a new resource group dialog with the Review and create option.

  8. Select Create.

Task - Create a language resource

If you've already created a language resource, skip to the next task.

  1. Go to Language Studio and sign in.

  2. Select your Azure directory and Azure subscription and then select Create a new language resource.

    Screenshot showing the Choose a language resource dialog, highlighting the Create a new language resource option.

  3. Select your Azure subscription, select the Azure resource group that you created, and then enter DemoLanguageResourceFL (replace FL with your initials) for the Azure resource name. Select your Location, select S for Pricing Tier, and then select Done.

    Screenshot showing the Create a new language resource dialog, showing details entered.

  4. After you've created the language resource, select Done.

Task - Copy the key and endpoint

Your next task is to copy the key and endpoint by following these steps:

  1. Go to the Microsoft Azure portal and sign in.

  2. Locate and open the language resource that you created.

    Screenshot of the language resources, with a resource highlighted.

  3. Select Keys and Endpoint.

  4. Copy Key 1 to the clipboard.

    Screenshot of the Copy to clipboard button highlighted.

  5. Save the key you that copied on a notepad. You'll need this key in future tasks.

  6. Copy the Endpoint URL.

  7. Save the URL on a notepad. You'll need this URL in future steps.

Exercise - Install WSL and Docker

In this exercise, you'll install the Windows Subsystem for Linux and Docker on Windows 10 or 11. If you aren't using Windows, go to Get Docker | Docker Documentation and follow the instructions for the operating system that you're using.

If you already have Docker installed on your machine, skip to the next exercise.

Task - Install Windows Subsystem for Linux

To install the Windows Subsystem for Linux, follow these steps:

  1. Locate your Command Prompt and select Run as administrator.

    Screenshot showing the Run as administrator command prompt.

  2. Select Yes.

  3. Run the following command to install Windows Subsystem for Linux. This command will install the default Ubuntu distribution.

    wsl --install

    Screenshot showing the command prompt.

  4. Select Yes and then wait for the installation to complete.

  5. Ensure that Ubuntu is installed successfully.

    Screenshot showing the successful installation of Windows Subsystem for Linux.

Task - Install Docker for Windows

Follow these steps to install Docker for Windows:

  1. Go to Get Docker | Docker Documentation.

  2. Select the operating system that you're using. In this exercise, you'll install Docker Desktop for Windows.

    Screenshot showing Docker Desktop for Windows.

  3. Select to download Docker Desktop for Windows.

  4. Run the Docker Desktop Installer that you downloaded.

    Screenshot showing Docker Desktop Installer.

  5. Select Yes if prompted.

  6. Select OK.

    Screenshot showing the Docker installation wizard.

  7. Wait for the installation to complete.

  8. Select Close and restart.

    Screenshot showing the Docker installation wizard with the Close and restart button.

    Docker should launch after your computer restarts.

  9. Read the agreement and select Accept if you agree.

  10. Select Sign in.

    Screenshot showing the Sign in button to sign in to Docker.

  11. Select Sign Up for personal account if you don't have a Docker account.

Exercise - Set up and run Docker

In this exercise, you'll set up and run Docker.

Task - Download and run the latest Docker version

To download and run the latest Docker version, follow these steps:

  1. Open Command Prompt.

  2. Run the following command, which will install the latest container version of Text Analytics for health.

    docker pull mcr.microsoft.com/azure-cognitive-services/textanalytics/healthcare:latest

    Screenshot showing the installation of the latest container of Text Analytics healthcare.

  3. Wait for the installation to complete.

  4. In the command prompt, run the following command. Replace {ENDPOINT_URL} and {API_KEY} with the URL and key that you copied from Azure.

    docker run --rm -it -p 5000:5000 mcr.microsoft.com/azure-cognitive-services/textanalytics/healthcare:latest Eula=accept rai_terms=accept Billing={ENDPOINT_URI} ApiKey={API_KEY}

  5. Select Allow access if Windows Defender prompts you.

Exercise - Use the container

This example shows you how to use the container to analyze single documents by using a demo user interface.

Task - Use the container

Follow these steps to use the container:

  1. Go to the Docker app and select Containers.

  2. Open the Port link.

    Screenshot showing the container port link.

  3. Add /demo to the end of the URL and then press the ENTER key.

    Screenshot showing the localhost URL.

  4. Enter Patient doesn't suffer from high blood pressure, or provide your own text, and then select Analyze.

    Screenshot showing the text to be analyzed.

    The result should resemble the following image.

    Screenshot showing the results.

  5. Provide the following in-depth text and then select Analyze.

    HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease, with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done in July, 2001, which showed no wall motion abnormalities, but this was a difficult study due to body habitus. The patient went for six minutes with minimal ST depressions in the anterior lateral leads, thought due to fatigue and wrist pain, his anginal equivalent. Due to the patient's increased symptoms and family history and history left main disease with total occasional of his RCA was referred for revascularization with open heart surgery.

  6. The result will resemble the following image. Hover your mouse pointer on the relation arrows to view the type of relation. Select the entities that have a UMLS value attached to them and then you can view the normalized name of the entity. The show JSON button allows you to view the raw results.

    Screenshot showing more complex results.

Exercise - Explore available endpoints

In this exercise, you'll explore the available endpoints for the container.

Task - Explore endpoints

To explore the available endpoints, follow these steps:

  1. Go to http://localhost:5000/swagger to view the available API for the container.

  2. Scroll down to the Health section, and then locate and expand /text/analytics/v3.1/entities/health.

    Screenshot showing the health API.

  3. Select Try it out.

    Screenshot showing the Try it out button.

  4. Review the Request body and then select the Execute button.

    Screenshot showing the Request body and the Execute button.

  5. Review the Response body.

    Screenshot showing the Response body.

Exercise - Call the container from the .NET application

In this exercise, you'll use the API from the .NET application that you created. If you don't have a .NET application, use the application from Cloud Service Lab or in the resources folder.

Task - Explore the application

To explore the application, follow these steps:

  1. Start Visual Studio and then open the .NET application.

  2. If you're using the application that you created, edit the application by providing space as the -credentials and http://localhost:5000 as the -endPoint.

    Screenshot showing the key and endpoint.

  3. Run the application.

  4. View the results, as shown in the following image.

    Screenshot showing the results in console.

  5. Stop the application.