DEV Community

Cover image for Getting started with Azure OpenAI
Juan Stoppa
Juan Stoppa

Posted on • Originally published at jstoppa.com

Getting started with Azure OpenAI

I've been exploring ways to use AI in my day-to-day job. I personally use Azure and want to leverage as much as possible the partnership they have with OpenAI.

What you will learn in this article is how to use your own data to create a ChatGPT-like agent using Azure OpenAI API.

What I'm using in this post includes:

  • Azure Open AI studio: a platform where Microsoft teamed up with OpenAI to give you access to their API directly from the Azure infrastructure. It's designed for developers and businesses that want to integrate AI into their apps or services, making them smarter and more intuitive.
  • Azure AI Search: a service designed to retrieve information across user-generated content, both in traditional search scenarios and in applications powered by generative AI. Whether you're developing applications that require conventional search functionalities or generative AI capabilities, this service delivers that for you.
  • Azure APP service: a service that allows you to quickly build, deploy and scale web apps and APIs. Work with most programming languages and runs on Windows or Linux.

Signing up for Open AI Studio

First things first, you'll need to create a Microsoft account and sign up for Azure Open AI Studio, best way if you don't have one already is to navigate to https://oai.azure.com/ and create a new account

Creating a Microsoft Account

At the time of writing this post, the Azure Open AI studio was in preview mode, if this is still valid you need to request access by submitting this form in customer voice https://customervoice.microsoft.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR7en2Ais5pxKtso_Pz4b1_xUNTZBNzRKNlVQSFhZMU9aV09EVzYxWFdORCQlQCN0PWcu

Using the Open AI studio

Once the account is created, you can access the studio by navigating to the URL https://oai.azure.com/, you'll be presented with some options on how to get started
Azure Open AI Studio main page

In the interest of this post, we'll be using the Chat functionality in the Playground area which I define below:

  1. Playground: this gives you the ability to test all the tools Azure Open AI Studio has, chat functionality, completions, DALL-E for generating images and assistants which are in preview mode at the time of creating this post.
  2. Prompts: this area is where you define your prompts, you can start them from templates or create your own prompts from scratch.
  3. Test the assistant: you can directly test your assistant in the playground by writing questions and interacting with it.

Azure Open AI Studio - Testing the assistant

To test its capability, I will use the Microsoft Annual Report from 2023, I have a version in PDF format. For this I will use the Azure AI Search capability from Microsoft that allows us to store the document and get the agent to search information in it.

NOTE: To add your data in the steps below, you'll first need to create an Azure AI Search service, follow the steps in this Microsoft article.

NOTE 2: It's also important that you create the resource in a region where the Open AI service is available

Follow the steps below to add your data

  1. Click on "Add your data"
  2. Followed by "Add a data source"

Azure Open AI Studio - Adding you own data in Open AI Studio

This will take you to a wizard where you need to complete the following:

  1. Select data source: this should be set to "Upload files"
  2. Subscription where the Azure AI Search has been created
  3. Select Azure Blob storage resource: a blob storage where the file can be uploaded
  4. Select Azure AI Search resource: selectable from the list, it's the service mentioned in the NOTE above
  5. Enter Index name: index to be created to search the data

Azure Open AI Studio - Adding Azure AI resource in Chat Playground

Add the file in the next page in the wizard and click on Upload files
Azure Open AI Studio - Adding PDF into Azure AI resource in Chat Playground

The next step is to select the type of search (Keyword) and then the chunk size which is 1024 by default
Azure Open AI Studio - Adding Keyword and chunk size into Azure AI resource in Chat Playground

Once finished, the ingestion progress will start which should take a few minutes

Querying the data

You can now ask any question to the agent and it should come with an answer about the document, for instance I have asked to give a summary of Microsoft 2023 Annual report and returned the following
Azure Open AI Studio - Adding Keyword and chunk size into Azure AI resource in Chat Playground

When answering the question, the chat result will show links to the sources which can be opened on the right hand side.
Azure Open AI Studio - Showing reference in Azure AI Studio within the Chat Playground

Another interesting feature is the ability to View the Code, this can be helpful to understand how the chat works and how the context is passed back and forth which enriches the conversation with the LLM.
Azure Open AI Studio - Showing code in Azure AI Studio within the Chat Playground

Deploying the app

With the Azure AI Studio is quite easy to deploy the APP in azure, you simply need to click on "Deploy to" > "A new web app...", you can either create a new app or select an existing.
Azure Open AI Studio - Showing code in Azure AI Studio within the Chat Playground

Once deployed, a link will show in the notification which will redirect you to the app
Azure Open AI Studio - App deployed from Azure AI Studio within the Chat Playground

It's also possible to customise the app to your needs using environments variables in Azure, you can check the possible options in this article, this should allow you to change the logo and some of the wording in the page

And that's all, you should have the app up and running now!

If you like the article, please follow me on X at @juanstoppa where a regularly post about AI.

Top comments (0)