Skip to content

Commit 363d64d

Browse files
authored
Merge pull request #268851 from MicrosoftDocs/main
3/12/2024 PM Publish
2 parents 4ca93b9 + b987118 commit 363d64d

File tree

80 files changed

+1414
-1634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1414
-1634
lines changed

articles/ai-services/openai/assistants-quickstart.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.topic: quickstart
99
author: mrbullwinkle
1010
ms.author: mbullwin
1111
ms.date: 02/01/2024
12-
zone_pivot_groups: openai-quickstart
12+
zone_pivot_groups: openai-quickstart-assistants
1313
recommendations: false
1414
---
1515

@@ -30,6 +30,12 @@ Azure OpenAI Assistants (Preview) allows you to create AI assistants tailored to
3030

3131
::: zone-end
3232

33+
::: zone pivot="programming-language-csharp"
34+
35+
[!INCLUDE [C# quickstart](includes/assistants-csharp.md)]
36+
37+
::: zone-end
38+
3339
::: zone pivot="rest-api"
3440

3541
[!INCLUDE [REST API quickstart](includes/assistants-rest.md)]
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---
2+
title: 'Quickstart: Use the OpenAI Service via the .NET SDK'
3+
titleSuffix: Azure OpenAI Service
4+
description: Walkthrough on how to get started with Azure OpenAI and make your first completions call with the .NET SDK.
5+
manager: masoucou
6+
author: aapowell
7+
ms.author: aapowell
8+
ms.service: azure-ai-openai
9+
ms.topic: include
10+
ms.date: 03/05/2024
11+
---
12+
13+
[Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/openai/Azure.AI.OpenAI/src) | [Package (NuGet)](https://www.nuget.org/packages/Azure.AI.OpenAI/)
14+
15+
## Prerequisites
16+
17+
- An Azure subscription - <a href="https://azure.microsoft.com/free/cognitive-services" target="_blank">Create one for free</a>
18+
- Access granted to Azure OpenAI in the desired Azure subscription
19+
20+
Currently, access to this service is granted only by application. You can apply for access to Azure OpenAI by completing the form at <a href="https://aka.ms/oai/access" target="_blank">https://aka.ms/oai/access</a>. Open an issue on this repo to contact us if you have an issue.
21+
- The [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
22+
- Azure OpenAI Assistants are currently available in Sweden Central, East US 2, and Australia East. For more information about model availability in those regions, see the [models guide](../concepts/models.md).
23+
- We recommend reviewing the [Responsible AI transparency note](/legal/cognitive-services/openai/transparency-note?context=%2Fazure%2Fai-services%2Fopenai%2Fcontext%2Fcontext&tabs=text) and other [Responsible AI resources](/legal/cognitive-services/openai/overview?context=%2Fazure%2Fai-services%2Fopenai%2Fcontext%2Fcontext) to familiarize yourself with the capabilities and limitations of the Azure OpenAI Service.
24+
- An Azure OpenAI resource with the `gpt-4 (1106-preview)` model deployed was used testing this example.
25+
26+
## Set up
27+
28+
### Create a new .NET Core application
29+
30+
In a console window (such as cmd, PowerShell, or Bash), use the `dotnet new` command to create a new console app with the name `azure-openai-quickstart`. This command creates a simple "Hello World" project with a single C# source file: *Program.cs*.
31+
32+
```dotnetcli
33+
dotnet new console -n azure-openai-assistants-quickstart
34+
```
35+
36+
Change your directory to the newly created app folder. You can build the application with:
37+
38+
```dotnetcli
39+
dotnet build
40+
```
41+
42+
The build output should contain no warnings or errors.
43+
44+
```output
45+
...
46+
Build succeeded.
47+
0 Warning(s)
48+
0 Error(s)
49+
...
50+
```
51+
52+
Install the OpenAI .NET client library with:
53+
54+
```console
55+
dotnet add package Azure.AI.OpenAI.Assistants --prerelease
56+
```
57+
58+
[!INCLUDE [get-key-endpoint](get-key-endpoint.md)]
59+
60+
[!INCLUDE [environment-variables](environment-variables.md)]
61+
62+
## Create an assistant
63+
64+
In our code we are going to specify the following values:
65+
66+
| **Name** | **Description** |
67+
|:---|:---|
68+
| **Assistant name** | Your deployment name that is associated with a specific model. |
69+
| **Instructions** | Instructions are similar to system messages this is where you give the model guidance about how it should behave and any context it should reference when generating a response. You can describe the assistant's personality, tell it what it should and shouldn't answer, and tell it how to format responses. You can also provide examples of the steps it should take when answering responses. |
70+
| **Model** | This is where you set which model deployment name to use with your assistant. The retrieval tool requires `gpt-35-turbo (1106)` or `gpt-4 (1106-preview)` model. **Set this value to your deployment name, not the model name unless it is the same.** |
71+
| **Code interpreter** | Code interpreter provides access to a sandboxed Python environment that can be used to allow the model to test and execute code. |
72+
73+
### Tools
74+
75+
An individual assistant can access up to 128 tools including `code interpreter`, as well as any custom tools you create via [functions](../how-to/assistant-functions.md).
76+
77+
Create and run an assistant with the following:
78+
79+
```csharp
80+
using Azure;
81+
using Azure.AI.OpenAI.Assistants;
82+
83+
string endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new ArgumentNullException("AZURE_OPENAI_ENDPOINT");
84+
string key = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY") ?? throw new ArgumentNullException("AZURE_OPENAI_API_KEY");
85+
AssistantsClient client = new AssistantsClient(new Uri(endpoint), new AzureKeyCredential(key));
86+
87+
// Create an assistant
88+
Assistant assistant = await client.CreateAssistantAsync(
89+
new AssistantCreationOptions("gpt-4-1106-preview") // Replace this with the name of your model deployment
90+
{
91+
Name = "Math Tutor",
92+
Instructions = "You are a personal math tutor. Write and run code to answer math questions.",
93+
Tools = { new CodeInterpreterToolDefinition() }
94+
});
95+
96+
// Create a thread
97+
AssistantThread thread = await client.CreateThreadAsync();
98+
99+
// Add a user question to the thread
100+
ThreadMessage message = await client.CreateMessageAsync(
101+
thread.Id,
102+
MessageRole.User,
103+
"I need to solve the equation `3x + 11 = 14`. Can you help me?");
104+
105+
// Run the thread
106+
ThreadRun run = await client.CreateRunAsync(
107+
thread.Id,
108+
new CreateRunOptions(assistant.Id)
109+
);
110+
111+
// Wait for the assistant to respond
112+
do
113+
{
114+
await Task.Delay(TimeSpan.FromMilliseconds(500));
115+
run = await client.GetRunAsync(thread.Id, run.Id);
116+
}
117+
while (run.Status == RunStatus.Queued
118+
|| run.Status == RunStatus.InProgress);
119+
120+
// Get the messages
121+
PageableList<ThreadMessage> messagesPage = await client.GetMessagesAsync(thread.Id);
122+
IReadOnlyList<ThreadMessage> messages = messagesPage.Data;
123+
124+
// Note: messages iterate from newest to oldest, with the messages[0] being the most recent
125+
foreach (ThreadMessage threadMessage in messages.Reverse())
126+
{
127+
Console.Write($"{threadMessage.CreatedAt:yyyy-MM-dd HH:mm:ss} - {threadMessage.Role,10}: ");
128+
foreach (MessageContent contentItem in threadMessage.ContentItems)
129+
{
130+
if (contentItem is MessageTextContent textItem)
131+
{
132+
Console.Write(textItem.Text);
133+
}
134+
Console.WriteLine();
135+
}
136+
}
137+
```
138+
139+
This will print an output as follows:
140+
141+
```
142+
2024-03-05 03:38:17 - user: I need to solve the equation `3x + 11 = 14`. Can you help me?
143+
2024-03-05 03:38:25 - assistant: The solution to the equation \(3x + 11 = 14\) is \(x = 1\).
144+
```
145+
146+
New messages can be created on the thread before re-running, which will see the assistant use the past messages as context within the thread.
147+
148+
## Clean up resources
149+
150+
If you want to clean up and remove an OpenAI resource, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it.
151+
152+
- [Portal](../../multi-service-resource.md?pivots=azportal#clean-up-resources)
153+
- [Azure CLI](../../multi-service-resource.md?pivots=azcli#clean-up-resources)
154+
155+
## See also
156+
157+
* Learn more about how to use Assistants with our [How-to guide on Assistants](../how-to/assistant.md).
158+
* [Azure OpenAI Assistants API samples](https://github.com/Azure-Samples/azureai-samples/tree/main/scenarios/Assistants)

articles/automation/automation-runbook-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The Azure Automation Process Automation feature supports several types of runboo
2121
| [Graphical PowerShell Workflow](#graphical-runbooks)|Graphical runbook based on Windows PowerShell Workflow and created and edited completely in the graphical editor in Azure portal. |
2222

2323
> [!NOTE]
24-
> Azure Automation will follow the support lifecycle of PowerShell and Python language versions in accordance with the timelines published by parent products [PowerShell](https://learn.microsoft.com/powershell/scripting/install/powershell-support-lifecycle?view=powershell-7.3&preserve-view=true#powershell-end-of-support-dates) and [Python](https://devguide.python.org/versions/) respectively. We recommend you to use runbooks with supported language versions.
24+
> Azure Automation will follow the support lifecycle of PowerShell and Python language versions in accordance with the timelines published by parent products [PowerShell](/powershell/scripting/install/powershell-support-lifecycle?view=powershell-7.3&preserve-view=true#powershell-end-of-support-dates) and [Python](https://devguide.python.org/versions/) respectively. We recommend you to use runbooks with supported language versions.
2525
2626
Take into account the following considerations when determining which type to use for a particular runbook.
2727

articles/azure-arc/data/includes/azure-arc-data-preview-release.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ ms.service: azure-arc
55
ms.custom:
66
- ignite-2023
77
ms.topic: include
8-
ms.date: 12/12/2023
8+
ms.date: 03/12/2024
99
---
1010

11-
<!--
1211
At this time, a test or preview build is not available for the next release.
13-
--->
14-
1512

13+
<!---
1614
March, 2024 preview release is now available.
1715
1816
|Component|Value|
@@ -48,3 +46,5 @@ Arc SQL Server | Backups | Configure backups at DB level for Arc enabled SQL Ser
4846
Arc SQL Server | Set feature flags via the Azure CLI | GA
4947
5048
Arc SQL Server | Billing | Support unlimited virtualization benefit for PAYG and Software Assurance customers | GA
49+
50+
-->

articles/azure-arc/data/plan-azure-arc-data-services.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ You can deploy Azure Arc-enabled data services on various types of Kubernetes cl
9494
- Additional [partner-validated Kubernetes distributions](./validation-program.md)
9595

9696
> [!IMPORTANT]
97-
> * The minimum supported version of Kubernetes is v1.21. For more information, see the "Known issues" section of [Release notes&nbsp;- Azure Arc-enabled data services](./release-notes.md#known-issues).
97+
> * The minimum supported version of Kubernetes is v1.21.
9898
> * The minimum supported version of OCP is 4.8.
9999
> * If you're using Azure Kubernetes Service, your cluster's worker node virtual machine (VM) size should be at least Standard_D8s_v3 and use Premium Disks.
100100
> * The cluster should not span multiple availability zones.
101-
> * For more information, see the "Known issues" section of [Release notes&nbsp;- Azure Arc-enabled data services](./release-notes.md#known-issues).
101+
> * For more information, review [Release notes](./release-notes.md).
102102
103103
## Deployment information
104104

0 commit comments

Comments
 (0)