Azure AI Foundry allows you to create enterprise-level intelligent apps and agents using Azure AI Agent Services, Azure AI Foundry Portal and the Azure AI Foundry SDK. Now Microsoft has released Azure AI Foundry for Visual Studio Code Extension, which allows enterprise developers to quickly create, debug, and maintain enterprise-grade AI Agents within VSCode.
Figure – Azure AI Foundry VSCode Extension
First, you need to install the Azure AI Foundry Visual Studio Code Extension from the VS Code extensions Marketplace.
After installing, click Azure in Visual Studio Code, log in, select your tenants for Azure AI Foundry
Choose the resources and click your project to access Agents and Models. Set the default project (use Command Palette: Set Default Project) before deploying an agent.
Figure – Choose Azure Tenants & Azure AI Foundry Default Project & Manage Agents / Models
Now that the Azure AI Foundry VS Code Extension is configured, let's talk about application scenarios.
Create and manage AI Agents
Create Agents
You can create Agents directly through the Azure AI Agents VS Code Extension. Here are the steps
- Select Agents and click the + button
Figure – Add AI Agents in Azure AI Foundry VSCode Extensions
- Select the local save location of the YAML file corresponding to AI Agents in Azure AI Foundry (you can manage the configuration files corresponding to each AI Agent locally)
Figure – Save AI Agents YAML format
After confirming the save location, you can enter the AI Agent's visual configuration interface
Figure – Set Configuration for Bing Search Agent
- Configure the AI Agent in the UI or YAML file. Set its Model, Instructions, Tools, and SETTINGS (Temperature and Top P) in the AI Agent UI.
Figure – Add Tool for Bing Search Agent
You can also configure it with YAMLtype: bing_grounding name: bing_search options: tool_connections: - >- Add your Bing Grounding Connection
Note: Tool settings must be configured through YAML. You can choose from Bing Grounding, Code Interpreter, File Search, and OpenAPI . Download Tools YAML - You can save the agent definition locally with YAML file or deploy the Agents to Azure AI Foundry directly.
Figure – Save AI Agent locally or Deploy to Azure AI Foundry
Test and maintain Agents
Select the Agent you want to use, right-click 'Open Playground', and test your Agent in the Playground
Figure – Choose Bing Agent to Open Playground
Figure – Chat Bing Agent Playground
Agents can be modified using either the user interface or YAML configuration (refer to Create Agents for further details).
Suggestions on how to use Azure AI Foundry VS Code Extension
The Azure AI Foundry VS Code Extension integrates with VS Code, accelerating development by maintaining Agents through YAML files. Here are some tips for effective use:
Better testing in multi-agent scenarios can be achieved by adjusting agents using YAML or UI. This allows easy parameter setting for different agents.
Combining this with Semantic Kernel is recommended, as it supports Azure AI Agent Service well. Use Semantic Kernel to orchestrate agent scenarios. (You can visit https://github.com/microsoft/semantic-kernel/tree/main/python/samples/getting_started_with_agents or https://github.com/microsoft/semantic-kernel/tree/main/dotnet/samples/GettingStartedWithAgents to learn how to use Semantic Kernel to orchestrate AI Agents )
For example, start with requirements, create the project structure, and generate code around the scenario in DevOps. Employ two agents: one for architecture and one for code generation.
Create DevOpsGenArch and DevOpsGenCode using the Azure AI Foundry VSCode Extension.
DevOpsGenArch - Responsible for the architecture and code, the corresponding configuration is as follows:
Figure – DevOpsGenArch Configuration
Testing with Playground
Figure – Testing in DevOpsGenArch Playground
DevOpsGenCode - Responsible for generating actual files based on the architecture and code and saving them as zip. The corresponding configuration is as follows:
Figure – DevOpsGenCode Configuration
Testing with UI
Figure – Testing in DevOpsGenArch Playground
If both tests pass, you can use Semantic Kernel to orchestrate Agents
async with (
DefaultAzureCredential() as creds,
AzureAIAgent.create_client(credential=creds) as client,
):
arch_agent_definition = await client.agents.get_agent(arch_agent_id)
code_agent_definition = await client.agents.get_agent(code_agent_id)
agent_arch = AzureAIAgent(
client=client,
definition=arch_agent_definition,
)
agent_code = AzureAIAgent(
client=client,
definition=code_agent_definition,
)
chat = AgentGroupChat(
agents=[agent_arch, agent_code],
termination_strategy=ApprovalTerminationStrategy(agents=[agent_code], maximum_iterations=10),
)
thread: AzureAIAgentThread = None
try:
# 6. Add the task as a message to the group chat
await chat.add_chat_message(message=TASK)
print(f"# {AuthorRole.USER}: '{TASK}'")
# 7. Invoke the chat
async for content in chat.invoke():
print(f"# {content.role} - {content.name or '*'}: '{content.content}'")
if content.name == "DevOpsGenCode":
if len(content.items) > 1:
file_name = f"{uuid.uuid4()}.zip"
await client.agents.save_file(file_id=content.items[1].file_id, file_name=file_name,target_dir="./arch")
finally:
# 8. Cleanup: Delete the agents
await chat.reset()
For further information, please download this Notebook.
Related resources
1. Blog about Azure AI Foundry VS Code Extension - https://aka.ms/azureaifoundry/vscode/blog
2. Extension marketplace - https://aka.ms/azureaifoundry/vscode
3. Using Azure AI Foundry Extension VSCode Docs - https://aka.ms/azureaifoundry/vscode/docs
4. Semantic Kernel Azure AI Agent with Python - https://github.com/microsoft/semantic-kernel/tree/main/python/samples/getting_started_with_agents/azure_ai_agent
5. Semantic Kernel Azure AI Agent with .NET - https://github.com/microsoft/semantic-kernel/tree/main/dotnet/samples/GettingStartedWithAgents/AzureAIAgent