Skip to content

Latest commit

 

History

History
65 lines (57 loc) · 5.38 KB

File metadata and controls

65 lines (57 loc) · 5.38 KB

Provision an Azure AI Services resource

  • Use any of the AI Services, create Azuew resources to define an endpoint where the service can be consumed, provide access keys for authenticated access, and to manage billing for your application's usage of the service.
  • Options for Azure resources
    1. Multi-service resource
      • You can provision an AI Services resource that supports multiple different AI Services. For example, create a single resource that enables you to use the AI Language, AI Vision, AI Speech, and other services.
      • Manage a single set of access credentials to consume multiple services at a single endpoint, and with a single point of billing for usage of all services.
    2. Single-service resource
      • Each AI service can be provisioned individually, for example by creating discrete AI Language and AI Vision resources in your Azure subscription.
      • Use separate endpoints for each service. Manage access credentials and for each service independently
      • Single-service resources generally offer a free tier (with usage restrictions), making them a good choice to try out a service before using it in a production application.
    3. Training and prediction resources
      • While most Azure AI Services can be used through a single Azure resource, some offer (or require) separate resources for model training and prediction.
      • Manage billing for training custom models separately from model consumption by applications, and in most cases enables you to use a dedicated service-specific resource to train a model, but a generic Azure AI Services resource to make the model available to applications for inferencing.

Identify endpoints and keys

  • To consume the service through the endpoint, applications require the following information:
    1. The endpoint URI - the Rest HTTP address. Client applications can send requests.
    2. A subscription key - Two keys that can be used for authentication (client applications can use either key to authenticate).
    3. The resource location - Where the resource is hosted. While most SDKs use the endpoint URI to connect to the service, some require the location.

Use a REST API

  • Azure AI Services provide REST APIs that client applications can use to consume services.

Use an SDK

  • An application that uses Azure AI Services using REST interfaces, but it's easier to build more complex solutions by using native libraries.
  • SDKs for languages such as: Microsoft C# (.NET Core), Python, JavaScript (Node.js), Go, Java

Exercise - Use Azure AI Services

  1. Start VSC -> Open the palette (SHIFT+CTRL+P) and run a Git: Clone -> enter clone url -> Open the folder
  • Provision an Azure AI Services resource
    1. Azure Portal -> Select Azure AI Services -> create an Azure AI services multi-service account resource -> Pricing tier: Standard S0
    2. Go to the resource -> Keys and Endpoint -> Get An HTTP endpoint, Two keys, the location
  • Use a REST Interface
    1. VSC -> 01-getting-started -> C-Sharp or Python -> rest-client or sdk-client folder -> configuration settings -> C#: appsettings.json OR Python: .env
    2. Code Review: C#: Program.cs OR Python: rest-client.py
    3. Various namespaces are imported to enable HTTP communication
    4. Main function -> retrieves the endpoint and key, used to send REST requests to the Text Analytics service.
    5. GetLanguage function -> call the Text Analytics language detection REST API endpoint to detect the language of the text that was entered.
    6. A collection of document JSON objects request contains with an id and text.
    7. The request header contains key to authenticate your client application.
    8. Right-click the rest-client folder -> integrated terminal -> Run - > dotnet run OR python rest-client.py
    9. Enter text (“Hello”, “Bonjour”, and “Gracias”) and review the language that is detected by the service.
  • Use an SDK
    1. SDK can greatly simplify development of applications that consume Azure AI services.
    2. VSC-> install the Text Analytics SDK package -> dotnet add package Azure.AI.TextAnalytics --version 5.3.0 OR pip install azure-ai-textanalytics==5.3.0
    3. Run -> dotnet run OR python sdk-client.py

Quiz

  1. How are client applications typically granted access to an Azure AI Services endpoint? 1. [x] The application must specify a valid subscription key for the Azure resource. 1. [ ] The user of the application must enter a user name and password associated with the Azure subscription. 1. [ ] Access to Azure AI Services is granted to anonymous users by default.
  2. In which format are message exchanged between a client app and an Azure AI Services resource when using a REST API? 1. [ ] XML 1. [x] JSON 1. [ ] HTML