Obtaining connection values for Microsoft Azure OpenAI

About this task

The following steps describe how to obtain the connection values for Microsoft Azure OpenAI and to connect to App Connect.

Procedure

  1. Log in to the Microsoft Azure portal.
  2. To obtain the client ID and client secret (OAUTH 2.0 CREDENTIALS and BASIC OAUTH) values, complete the following steps:
    1. Click App registrations.
    2. In the App registrations page, click New registration.
    3. In the Register an application page, specify a unique name for your app.
    4. Select an option in the Supported account types section according to your requirements:

      For the OAUTH 2.0 CREDENTIALS authorization type, select the Single tenant option.

      For the BASIC OAUTH authorization type, select one of the Multitenant options.

      registering an application
    5. Click Register.

      The Overview page for the application is displayed.

      Overview page for the registered application
    6. Make a note of the Application (client) ID value because you need to specify it as a connection value when creating the account in App Connect.
    7. For the Client credentials field on the Overview page, click Add a certificate or secret. This action opens the Certificates & secrets page.
      Certificates & secrets page for the registered application
    8. Click + New client secret.
    9. In the Add a client secret panel, specify a description for the secret (for example, App Connect secret) and then select an expiry period.
    10. Click Add.

      The generated client secret is displayed on the Certificates & secrets page.

      Generated client secret for the registered app
    11. Copy and store the client secret value. You need to specify this value as a connection value when you create the account in App Connect.
      Note: The client secret value is not shown again in full after you exit this page.
  3. To configure the permissions that App Connect needs, complete the following steps:
    1. Click App registrations.
    2. Select the application that you created in step 2.
    3. Click Manage.
    4. Click API permissions on the sidebar.
    5. Click +Add a permission.
    6. Select Microsoft Cognitive Services.
    7. Select user_impersonation under Permissions.
    8. Click the Add permissions button.
      Configured permissions for the application
  4. To find the tenant ID (OAUTH 2.0 CREDENTIALS) value, complete the following steps:
    1. Go to the Microsoft Azure portal login page, and then go to Microsoft Entra ID > Properties.
    2. Copy the Tenant ID value and save it somewhere safe.
      Locating the Tenant ID in Microsoft Entra ID

      For more information about obtaining the Tenant ID, see How to find your Microsoft Entra tenant ID in the Microsoft Entra documentation.

  5. To create a new resource in Microsoft Azure OpenAI, complete the following steps:
    1. Log in to the Microsoft Azure portal.
    2. Click Azure OpenAI from the list of Azure Services.
    3. Click +Create, and then select Azure OpenAI.
    4. Choose the subscription in which you want to create the resource.
    5. Select a resource group from the menu, or click Create new to create a new resource group.
    6. In the Region field, choose the region to host your resource.
    7. Enter the name for your resource in the Name field.
    8. In the Pricing tier field, select the required pricing tier.
    9. Click Next.
    10. On the Networks tab, select the Type that you require.
    11. Click Next.
    12. On the Tags tab, configure the tags you require.
    13. Click Next.
    14. Review and confirm your settings, and then click Create.
      Tip: For more information about creating a resource, see Create a resource in the Microsoft Azure documentation.
  6. To grant your application access to the Azure Open AI resource by using Azure role-based access control (Azure RBAC), assign the Cognitive Services OpenAI Contributor and Cognitive Services OpenAI User roles to the application.
    1. Go to the Microsoft Azure portal, and then click Azure OpenAI from the list of Azure Services.
    2. Select the Azure OpenAI resource that you created in step 5.
    3. Click Access control (IAM) on the sidebar.
    4. Click +Add, and then select Add role assignment.

      The Add role assignment page is displayed.

    5. In the Role field, select Cognitive Services OpenAI Contributor and Cognitive Services OpenAI User from the list.
    6. In the Members section, select the application that you created in step 2.
    7. Click Review + assign.
      Tip: For more information about assigning a role, see Add role assignment to an Azure OpenAI resource in the Microsoft Azure documentation.
  7. To obtain the Server URL and the API key (API KEY), complete the following steps:
    1. Go to the Microsoft Azure portal.
    2. Click Azure OpenAI from the list of Azure Services.
    3. Select the resource that you created in step 5.
    4. Click Go to Foundry portal.
      Locating API Key and Azure Open AI endpoint
    5. Copy your API key value and save it somewhere safe.
    6. Copy the Azure OpenAI endpoint (this is your Server URL) value and save it somewhere safe.
  8. If you want to connect by using BASIC OAUTH authorization, use an application to submit a POST request to generate an access token and a refresh token that will be used to interact with Microsoft Azure OpenAI on your behalf. Before you can request an access token, you must authorize your application.

    To authorize the application, complete the following steps:

    1. Open a browser window, and then go to the authorization endpoint by using a URL in the following format:
      Request URL:
      GET https://login.microsoftonline.com/common/oauth2/v2.0/authorize
      Request parameters:
      Key Value
      client_id Set this to the Application (client) ID value that was generated for your registered app.
      response_type Set this to code to indicate that the app is using the OAuth 2.0 authorization code flow.
      redirect_uri Set this to the redirect URI registered for your application. This value must exactly match one of the registered redirect URIs and must be URL encoded. For native and mobile apps, use the default value of https://login.microsoftonline.com/common/oauth2/nativeclient.
      scope A list of permissions, which are separated by spaces, that the user must consent to. For example, https://cognitiveservices.azure.com/.default offline_access
      response_mode Set this to specify how the authorization response is returned to the application. Valid values are query or form_post or fragment.
      state Set this to a unique value to maintain request state and help protect against cross‑site request forgery (CSRF) attacks.
    2. Enter your Microsoft account credentials, and then click Sign in.
    3. Review the permissions in the Permissions requested pop-up window and click Accept.
      The browser is redirected to the configured redirect URI. For example:
      GET http://localhost?
      code=AwABAAAAvPM1KaPlrEqdFSBzjqfTGBCmLdgfSTLEMPGYuNHSUYBrq...
      &state=12345
    4. Copy and save the value of the code query parameter in the redirected URL.
  9. To generate an access token and a refresh token (BASIC OAUTH), submit a POST request to the token endpoint by specifying the following parameters:
    • Token endpoint URL:
      POST
      https://login.microsoftonline.com/common/oauth2/v2.0/token
    • Content-Type: application/x-www-form-urlencoded
    • Request parameters:
      Key Value
      client_id Set this to the Application (client) ID value that was generated for your registered app.
      scope A space-separated list of scopes. For example, https://cognitiveservices.azure.com/.default offline_access
      grant_type Set this to authorization_code
      client_secret Set this to the client secret value that was generated under Certificates & secrets for your registered app.
      code Set this to the code that you acquired in step 8.
      redirect_uri Set this to the same redirect URI used in step 8 .