How to deploy Azure OpenAI chat with Copilot Studio Agent
Hi Yogesh Borse,
Welcome to Microsoft Q&A and Thank you for reaching out.
Now you want to deploy the solution as a conversational agent inside Microsoft Copilot Studio, not as a standalone web app.
Create an Azure Function App or Web API in C#, Python.
Implement this logic:
Accept natural language input from the user.
Send it to your Azure OpenAI endpoint.
Use Azure AI Search to enrich context.
Generate and execute a dynamic SQL query on Azure SQL Database.
Return the final response as JSON.
Deploy it to Azure and note the public endpoint URL. 2: Prepare Knowledge Sources in Copilot Studio
Copilot Studio can directly connect to:
Azure AI Search
Custom APIs (your backend)
To add Azure AI Search: Go to copilotstudio.microsoft.com
Select your environment.
Click Knowledge → Add a source
Choose Azure AI Search
Enter your: Search service name, Index name,API key,Region
3: Create a New Agent in Copilot Studio
To create an agent:
Open Microsoft Teams and Install Copilot Studio from the Teams app store
Open Copilot Studio and Click Create a copilot and Name your agent and choose the correct team and environment
4: Connect Your API via a Custom Action
Now, connect your backend API to Copilot Studio.
To add your API:
In your Copilot project, go to Plugins → Custom actions
Click + Add a custom action
Select Create from API definition
Upload your OpenAPI (Swagger) spec OR manually define:
API name
Endpoint URL
HTTP method
Request/response schema
Headers
After saving, test the connection and action.
5: Build Your Chat Flow
Now set up how your Copilot handles input and returns dynamic SQL results.
To build the flow:Go to Topics → Create a new topic (“Dynamic SQL Query”)
Add trigger phrases (Like “How many sales last week?”, “Show me revenue by region”)
In the flow editor:
Add a message to acknowledge the query
Add a step to call your custom action (API)
Add a message to display the returned result to the user
6: Test Your Agent
Copilot Studio has a built-in test chat window.
To test:
Click Test your copilot and Enter a natural language question Confirm it:
Sends to your API
Generates and executes SQL correctly
Returns useful data to the user
Fix any issues with response format or API timeout.
7: Publish & Deploy to Microsoft Teams
To publish:
Click Publish → Next → Publish now
To deploy to Teams:
Go to Channels
Click Microsoft Teams
References:
learn.microsoft.com/en-us/microsoft-cloud/dev/copilot/overview#build-your-own-copilot
learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/responses?tabs=python-key
If this answers your query, please do click Accept Answer and Yes for was this answer helpful.
Thank you!
Read more here: Source link
