# Azure OpenAI

## Overview

Azure OpenAI integration allows you to integrate your own models into Datasaur. This functionality provides three key benefits:

1. **Integrating your own LLMs**: This feature enables you to bring your own models into LLM Labs. Datasaur will retrieve all available Azure OpenAI models based on your credentials. Once connected, these models will be accessible to all workspace members.
2. **Protect your data**: By using your own LLMs, you can ensure better security compliance, providing you with complete control and privacy over your data.
3. **Streamlined workflow:** Access your preferred models directly within Datasaur's user-friendly interface, simplifying your LLM workflows to allows you to gain insights about your model's performance by comparing it to other models, both within and outside of Azure.

## Setup

### Integrate Azure OpenAI using application role

1. Navigate to the **Models** page under LLM Labs menu.
2. Open **My models** tab, and click the **Manage providers** button.
3. Choose **Azure OpenAI** as the provider, and enter your Tenant ID, Subscription ID, Resource group name, and Account name.

   <figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-d6c0e3808b2c04af3006dc59d91a552c7adef591%2FModels%20-%20Manage%20providers%20dialog%20-%20Azure%20OpenAI%20-%20Role%20-%20Initial.png?alt=media" alt=""><figcaption></figcaption></figure>
4. If this is your first time integrating Azure Open AI with Datasaur, click **Add Datasaur to your Azure Tenant** to grant consent for Datasaur's App Registration to your tenant. If you have previously done this, you can skip this step.
   * You must have at least the **Privileged Role Administrator** role to grant consent to App Registrations for delegated access. Continue the process on a new tab and authorize the Datasaur app. Note that you need **Admin** permission to complete this action.

     <figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-60e42f2e96fcbb523feee893d15542da359f2bc1%2FModels%20-%20Manage%20providers%20dialog%20-%20Azure%20OpenAI%20-%20Microsoft%20-%20permission%20requested.png?alt=media" alt=""><figcaption></figcaption></figure>
5. **Grant role assignments to Datasaur's Service Principal**
   1. Still in the **Azure OpenAI Account**, find **Access Control (IAM)** on the sidebar.
   2. Click **Add** > **Add role assignment**.
   3. Select **Cognitive Services OpenAI Contributor**, then click **Next**.
   4. In **Assign access to**, click **User, group, or service principal**, then click **select members**.
   5. Search for **Datasaur Azure AI Integrator** (you cannot see the service principals from the list, you must search for them), then add it. This step will not be available if you haven't added Datasaur to your Azure tenant as described above.
6. Click **Next**, and when you reach the **Conditions** section, click **Next** again.
7. Click **Review + assign**.
8. **Getting the Tenant ID:**
   1. Go to your **Microsoft** **Entra ID** from the Azure portal. [Learn more about Microsoft Entra ID](https://learn.microsoft.com/en-us/entra/fundamentals/whatis)
   2. Under the **Overview** tab, copy the **Tenant ID** attribute under the **Basic information** section.
9. **Getting the Subscription ID, Resource Group Name, and Account Name:**
   1. Go to the **Azure OpenAI** page from the Azure portal.
   2. Create or select an **Azure OpenAI Account**.
   3. From the sidebar, click **Overview**.
   4. You should find these fields under the **Essentials** section **Subscription ID** should be available as “**Subscription ID” Resource Group Name** should be available as “**Resource group**” **Account Name** is the name of the selected **Azure OpenAI Account.**

      <figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-68c59de9075124791449e694d5c7d1d1cfbe2f7a%2FModels%20-%20Manage%20providers%20dialog%20-%20Azure%20OpenAI%20-%20Microsoft%20-%20Overview.png?alt=media" alt=""><figcaption></figcaption></figure>
10. Once you have connected your Azure OpenAI Models to LLM Labs, you will see a list of available LLM Models that you have already deployed in Azure OpenAI. You can immediately use these models within LLM Labs.

    <figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-c9f88ad6b00f9ab8dc0ac5094789a2daac07c6fe%2FModels%20-%20Manage%20providers%20dialog%20-%20Azure%20OpenAI%20-%20models%20retrieved.png?alt=media" alt=""><figcaption><p>Azure OpenAI connected</p></figcaption></figure>

{% hint style="info" %}
Every new model that you deploy in Azure OpenAI will be synced to Datasaur, and you can use it right away in Datasaur. If the models you just deployed haven't appeared on Datasaur, you can click Sync models.
{% endhint %}

### Integrate Azure OpenAI using application certificate

This section provides a step-by-step guide for integrating Azure OpenAI with Datasaur’s LLM Labs using a certificate for secure authentication. You’ll learn how to generate credentials, upload the certificate to Azure, and connect Azure OpenAI to LLM Labs.

{% hint style="info" %}
If you are connecting to Azure OpenAI using a certificate, note that only the deployment name that matches the format `modelName-modelVersion` will be integrated with LLM Labs.
{% endhint %}

#### **Step 1: Generate Credentials**

To integrate Azure Open AI using a certificate, you need to generate a private key, extract the public key, and combine them into a single PEM file.

1. **Generate a private key**

   If you don’t have a private key, generate one using the following command:

   `openssl genrsa -out private.pem 2048`
2. **Extract the public key from the private key**

   Use the private key to generate a public key in `.pem` format:

   `openssl req -new -x509 -key private.pem -out public.pem -days 365`
3. **Combine keys into one PEM file**

   Combine the private and public keys into a single `.pem` file:

   `cat private.pem public.pem > fullkeys.pem`

#### **Step 2: Upload the Certificate to Azure App Registration**

1. **Access Azure Portal:** Log in to the [Azure Portal](https://portal.azure.com/).
2. **Navigate to App Registrations**
   * Go to **Azure Active Directory** > **App registrations**.
   * Select your application.
3. **Upload the certificate**
   * In the left menu, go to **Certificates & secrets**.
   * Under the **Certificates** section, click **Upload certificate**.
   * Choose your `.pem` (public key) file and upload it.
4. **Retrieve Tenant ID and Client ID**
   * On your application page, go to the **Overview** section.
   * Copy the **Tenant ID** and **Client ID**. These will be required to connect Azure Open AI to LLM Labs.
   * Ensure your application has access to the Azure Open AI service you want to connect to.

#### Step 3: Connect Azure Open AI Provider in LLM Labs

1. Navigate to the **Models catalog** in your Datasaur workspace, and click **Manage providers**.
2. Choose **Azure OpenAI** as the provider, and select **Azure tenant application certificate**.

   <figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-10dccba0caf44e0365f1b35b26a3c3365c56a9bf%2FModels%20-%20Manage%20providers%20dialog%20-%20Azure%20OpenAI%20-%20Certificate%20-%20Initial.png?alt=media" alt=""><figcaption></figcaption></figure>
3. Enter your **Tenant ID**, **Client ID**, and **Azure OpenAI** **endpoint**.
4. Upload the `.pem` file containing both the private and public keys (created in Step 1).

## Supported Azure OpenAI Models

Datasaur supports a wide range of models available in Azure OpenAI. You can find the list of supported models here: [Azure OpenAI Models](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models).

{% hint style="info" %}
Currently, Datasaur only provides support for text generation Large Language Models.
{% endhint %}

Additionally, you can bring your own **fine-tuned models** from Azure OpenAI into Datasaur, allowing for greater customization and performance tailored to your specific use cases.

## Disconnect Azure OpenAI

To disconnect Azure OpenAI from Datasaur, follow these steps:

1. Click **Manage providers**, then click **View details** on Azure OpenAI provider.

   <figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-402a3864b922889ff651c1da7b52b75ba37661d3%2FModels%20-%20Manage%20providers%20dialog%20-%20Azure%20OpenAI%20-%20connected.png?alt=media" alt=""><figcaption></figcaption></figure>
2. In the dialog that opens, click **Disconnect** at the bottom left.

   <figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-e3fab07853534770a3dbb14b1aba089d8af1e391%2FModels%20-%20Manage%20providers%20dialog%20-%20Azure%20OpenAI%20-%20Certificate%20-%20provider%20details.png?alt=media" alt=""><figcaption></figcaption></figure>

## Availability

The model will be accessible to all workspace members for use in their projects. Additionally, only the **Admin** can remove the Azure OpenAI provider from the workspace.

## Conclusion

Integrating your own Azure OpenAI models with Datasaur not only enhances functionality but also ensures that your data remains secure and compliant with your organization's policies. By leveraging your own LLMs, you gain greater control, customization, and security for your AI applications.

For further assistance or to get started, please reach out to our support team at <support@datasaur.ai>.
