Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main into live #42405

Merged
merged 8 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions docs/azure/includes/dotnet-all.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/azure/sdk/authentication/additional-methods.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Additional methods to authenticate to Azure from .NET apps
description: This article describes additional, less common methods you can use to authenticate your .NET app to Azure resources.
description: This article describes additional, less common methods you can use to authenticate your .NET app to Azure resources.
ms.topic: how-to
ms.custom: devx-track-dotnet, engagement-fy23
ms.date: 08/15/2024
Expand Down Expand Up @@ -101,7 +101,7 @@ The following example shows how to enable sign-in with the default system accoun

:::code language="csharp" source="../snippets/authentication/additional-auth/interactive/SilentBrokeredAuth.cs" highlight="16-24":::

Once you opt into this behavior, the credential attempts to sign in by asking the underlying Microsoft Authentication Library (MSAL) to perform the sign-in for the default system account. If the sign-in fails, the credential falls back to displaying the account picker dialog, from which the user can select the appropriate account.
Once you opt in to this behavior, the credential attempts to sign in by asking the underlying Microsoft Authentication Library (MSAL) to perform the sign-in for the default system account. If the sign-in fails, the credential falls back to displaying the account picker dialog, from which the user can select the appropriate account.

## Device code authentication

Expand Down
49 changes: 23 additions & 26 deletions docs/azure/sdk/protocol-convenience-methods.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: Understand Azure SDK client library method types
description: Learn about the key differences between Azure SDK client library protocol and convenience methods.
description: Learn about the key differences between protocol and convenience methods in the Azure SDK client libraries for .NET.
ms.topic: conceptual
ms.custom: devx-track-dotnet, engagement-fy23, devx-track-arm-template
ms.date: 08/29/2024
ms.date: 08/30/2024
---

# Azure SDK for .NET protocol and convenience methods overview
Expand All @@ -15,15 +15,13 @@ The Azure SDK client libraries provide an interface to Azure services by transla
An Azure SDK for .NET client library can expose two different categories of methods to make requests to an Azure service:

- **Protocol methods** provide a thin wrapper around the underlying REST API for a corresponding Azure service. These methods map primitive input parameters to HTTP request values and return a raw HTTP response object.

- **Convenience methods** provide a convenience layer over the lower-level protocol layer to add support for the .NET type system and other benefits. Convenience methods accept primitives or .NET model types as parameters and map them to the body of an underlying REST API request. These methods also handle various details of request and response management to allow developers to focus on sending and receiving data objects, instead of lower-level concerns.

### Azure SDK client library dependency patterns

Protocol and convenience methods implement slightly different patterns based on the underlying package dependency chain of the respective library. An Azure SDK for .NET client library depends on one of two different foundational libraries:

- [**Azure.Core**](/dotnet/api/overview/azure/core-readme) provides shared primitives, abstractions, and helpers for building modern Azure SDK client libraries. These libraries follow the [Azure SDK Design Guidelines for .NET](https://azure.github.io/azure-sdk/dotnet_introduction.html) and use package names and namespaces prefixed with *Azure*, such as [`Azure.Storage.Blobs`](/dotnet/api/overview/azure/storage.blobs-readme).

- [**System.ClientModel**](/dotnet/api/overview/azure/system.clientmodel-readme) is a core library that provides shared primitives, abstractions, and helpers for .NET service client libraries. The `System.ClientModel` library is a general purpose toolset designed to help build libraries for various platforms and services, whereas the `Azure.Core` library is specifically designed for building Azure client libraries.

> [!NOTE]
Expand All @@ -34,8 +32,8 @@ The following table compares some of the request and response types used by prot
| Request or response concern | Azure.Core | System.ClientModel |
|-------------------------------|----------------------------------|-------------------------------------------------------|
| Request body | <xref:Azure.Core.RequestContent> | <xref:System.ClientModel.BinaryContent> |
| Advanced options | <xref:Azure.RequestContext> | <xref:System.ClientModel.Primitives.RequestOptions> |
| Raw HTTP Response | <xref:Azure.Response> | <xref:System.ClientModel.Primitives.PipelineResponse> |
| Advanced request options | <xref:Azure.RequestContext> | <xref:System.ClientModel.Primitives.RequestOptions> |
| Raw HTTP response | <xref:Azure.Response> | <xref:System.ClientModel.Primitives.PipelineResponse> |
| Return type with output model | <xref:Azure.Response%601> | <xref:System.ClientModel.ClientResult%601> |

The sections ahead provide implementation examples of these concepts.
Expand All @@ -52,7 +50,7 @@ Azure SDK client libraries adhering to the [latest design guidelines](https://az

The following code uses a `ContentSafetyClient` to call the `AnalyzeText` convenience method:

:::code source="snippets/protocol-convenience-methods/AzureCoreConvenience/Program.cs" highlight="10":::
:::code source="snippets/protocol-convenience-methods/AzureCore/Convenience/Program.cs" highlight="10":::

The preceding code demonstrates the following `Azure.Core` convenience method patterns:

Expand All @@ -63,17 +61,18 @@ The preceding code demonstrates the following `Azure.Core` convenience method pa

The following code uses a `ContentSafetyClient` to call the `AnalyzeText` protocol method:

:::code source="snippets/protocol-convenience-methods/AzureCoreProtocol/Program.cs" highlight="19-24":::
:::code source="snippets/protocol-convenience-methods/AzureCore/Protocol/Program.cs" highlight="19-24":::

The preceding code demonstrates the following protocol method patterns:
The preceding code demonstrates the following `Azure.Core` protocol method patterns:

- Uses the `RequestContent` type to supply data for the request body.
- Uses the `RequestContext` type to configure request options.
- Returns data using the `Response` type.
- Reads content from the response data into a [dynamic](../../csharp/advanced-topics/interop/using-type-dynamic.md) type using <xref:Azure.AzureCoreExtensions.ToDynamicFromJson%2A>. For more information, see [Announcing dynamic JSON in the Azure Core library for .NET](https://devblogs.microsoft.com/azure-sdk/dynamic-json-in-azure-core/).
1. **Create the request**, using a `RequestContent` object for the request body.
1. **Invoke the protocol method**, using a `RequestContext` object to configure request options.
1. **Handle the response** by reading:
- The HTTP status code from the `Response` object to determine success or failure.
- Data from the `Response` object's content into a [dynamic](../../csharp/advanced-topics/interop/using-type-dynamic.md) type using <xref:Azure.AzureCoreExtensions.ToDynamicFromJson%2A>. For more information, see [Announcing dynamic JSON in the Azure Core library for .NET](https://devblogs.microsoft.com/azure-sdk/dynamic-json-in-azure-core/).

> [!NOTE]
> The preceding code configures the `ClientErrorBehaviors.NoThrow` for the `RequestOptions`. This option prevents non-success service responses status codes from throwing an exception, which means the app code should manually handle the response status code checks.
> The preceding code configures the [ErrorOptions.NoThrow](/dotnet/api/azure.erroroptions) behavior. This option prevents non-success service responses status codes from throwing an exception, which means the app code should manually handle the response status code checks.

---

Expand All @@ -85,7 +84,7 @@ Some client libraries that connect to non-Azure services use patterns similar to

Consider the following code that uses a `ChatClient` to call the `CompleteChat` convenience method:

:::code source="snippets/protocol-convenience-methods/SCMConvenience/Program.cs" highlight="9":::
:::code source="snippets/protocol-convenience-methods/SCM/Convenience/Program.cs" highlight="9":::

The preceding code demonstrates the following `System.ClientModel` convenience method patterns:

Expand All @@ -96,14 +95,15 @@ The preceding code demonstrates the following `System.ClientModel` convenience m

The following code uses a `ChatClient` to call the `CompleteChat` protocol method:

:::code source="snippets/protocol-convenience-methods/SCMProtocol/Program.cs" highlight="26-31":::
:::code source="snippets/protocol-convenience-methods/SCM/Protocol/Program.cs" highlight="26-31":::

The preceding code demonstrates the following `System.ClientModel` protocol method patterns:

- Uses the `BinaryContent` type as a parameter to supply data for the request body.
- Uses the `RequestContext` type to configure request options.
- Returns data using the `ClientResult` type.
- Calls the <xref:System.ClientModel.ClientResult.GetRawResponse%2A> method to access the response data.
1. **Create the request**, using a `BinaryContent` object for the request body.
1. **Invoke the protocol method**, using a `RequestOptions` object to configure request options.
1. **Handle the response** by reading:
- The HTTP status code from the `PipelineResponse` object to determine success or failure.
- Data from the `PipelineResponse` object's content using `System.Text.Json` APIs.

> [!NOTE]
> The preceding code configures the [ClientErrorBehaviors.NoThrow](/dotnet/api/system.clientmodel.primitives.clienterrorbehaviors) behavior for the `RequestOptions`. This option prevents non-success service responses status codes from throwing an exception, which means the app code should manually handle the response status code checks.
Expand All @@ -113,9 +113,8 @@ A `System.ClientModel`-based response can be processed like a convenience model,
```diff
PipelineResponse response = result.GetRawResponse();

- BinaryData output = result.GetRawResponse().Content;
- using JsonDocument outputAsJson = JsonDocument.Parse(output);
- JsonElement message = outputAsJson.RootElement
- using JsonDocument output = JsonDocument.Parse(response.Content);
- JsonElement message = output.RootElement
- .GetProperty("choices"u8)[0]
- .GetProperty("message"u8);

Expand Down Expand Up @@ -147,6 +146,4 @@ Protocol methods:

## See also

- [Understanding the Azure Core library for .NET](https://devblogs.microsoft.com/azure-sdk/understanding-the-azure-core-library-for-net/)
- [Azure.Core library for .NET](/dotnet/api/overview/azure/core-readme)
- [System.ClientModel library for .NET](/dotnet/api/overview/azure/system.clientmodel-readme)
[Understanding the Azure Core library for .NET](https://devblogs.microsoft.com/azure-sdk/understanding-the-azure-core-library-for-net/)
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.AI.ContentSafety" Version="1.0.0" />
<PackageReference Include="Azure.Identity" Version="1.12.0" />
<PackageReference Include="Azure.AI.ContentSafety" />
<PackageReference Include="Azure.Identity" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Azure.AI.ContentSafety" Version="1.0.0" />
<PackageVersion Include="Azure.Identity" Version="1.12.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.AI.ContentSafety" Version="1.0.0" />
<PackageReference Include="Azure.Identity" Version="1.12.0" />
<PackageReference Include="Azure.AI.ContentSafety" />
<PackageReference Include="Azure.Identity" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenAI" Version="2.0.0-beta.10" />
<PackageReference Include="OpenAI" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="OpenAI" Version="2.0.0-beta.10" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
throw new ClientResultException(response);
}

BinaryData output = result.GetRawResponse().Content;
using JsonDocument outputAsJson = JsonDocument.Parse(output);
JsonElement message = outputAsJson.RootElement
using JsonDocument output = JsonDocument.Parse(response.Content);
JsonElement message = output.RootElement
.GetProperty("choices"u8)[0]
.GetProperty("message"u8);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenAI" Version="2.0.0-beta.10" />
<PackageReference Include="OpenAI" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions docs/core/compatibility/9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff
| [DefaultKeyResolution.ShouldGenerateNewKey has altered meaning](aspnet-core/9.0/key-resolution.md) | Behavioral change | Preview 3 |
| [HostBuilder enables ValidateOnBuild/ValidateScopes in development environment](aspnet-core/9.0/hostbuilder-validation.md) | Behavioral change | Preview 7 |

## Containers

| Title | Type of change | Introduced version |
|-----------------------------------------------------------------------------|-------------------|--------------------|
| [.NET 9 container images no longer install zlib](containers/9.0/no-zlib.md) | Behavioral change | Preview 7 |

## Core .NET libraries

| Title | Type of change | Introduced version |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The original behavior is considered a bug in the implementation. As a goal, the

## Recommended action

If upgrading from previous versions of Blazor to 5.x, use the `PreferExactMatches` attribute on the `Router` component. This attribute can be used to opt into the correct behavior. For example:
If upgrading from previous versions of Blazor to 5.x, use the `PreferExactMatches` attribute on the `Router` component. This attribute can be used to opt in to the correct behavior. For example:

```razor
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For discussion, see issue [dotnet/aspnetcore#22807](https://github.com/dotnet/as

Before ASP.NET Core 5.0 Preview 6, Kestrel didn't support changing configuration at run time.

In ASP.NET Core 5.0 Preview 6, you could opt into the now-default behavior of reacting to configuration changes at run time. Opting in required binding Kestrel's configuration manually:
In ASP.NET Core 5.0 Preview 6, you could opt in to the now-default behavior of reacting to configuration changes at run time. Opting in required binding Kestrel's configuration manually:

```csharp
using Microsoft.AspNetCore.Hosting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ Rate-limiting middleware requires services that are only registered by calling <

## Recommended action

Ensure that <xref:Microsoft.AspNetCore.Builder.RateLimiterApplicationBuilderExtensions.UseRateLimiter%2A> is called at application startup.
Ensure that <xref:Microsoft.AspNetCore.Builder.RateLimiterServiceCollectionExtensions.AddRateLimiter%2A> is called at application startup.

For example, update `Configure<RateLimiterOptions>(o => { })` to use <xref:Microsoft.AspNetCore.Builder.RateLimiterApplicationBuilderExtensions.UseRateLimiter%2A>:
For example, update `Configure<RateLimiterOptions>(o => { })` to use <xref:Microsoft.AspNetCore.Builder.RateLimiterServiceCollectionExtensions.AddRateLimiter%2A>:

```csharp
var builder = WebApplication.CreateBuilder(args);
Expand Down
2 changes: 1 addition & 1 deletion docs/core/compatibility/containers/8.0/app-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ms.custom: linux-related-content
---
# New non-root 'app' user in Linux images

The .NET Linux container images include a new non-root user named `app`. You can opt into this new user to provide security benefits. The name of this user may conflict with an existing user defined by an application's Dockerfile.
The .NET Linux container images include a new non-root user named `app`. You can opt in to this new user to provide security benefits. The name of this user may conflict with an existing user defined by an application's Dockerfile.

## Previous behavior

Expand Down
38 changes: 38 additions & 0 deletions docs/core/compatibility/containers/9.0/no-zlib.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: ".NET 9 container images no longer install `zlib`"
description: Learn about the breaking change in containers where .NET 9 container images no longer install the zlib package.
ms.date: 08/29/2024
---
# .NET 9 container images no longer install zlib

.NET 9 container images no longer install `zlib` since it's not a dependency of the .NET Runtime anymore.

## Previous behavior

In previous .NET versions, .NET container images installed the latest version of the `zlib` package from the Linux base image package repositories.

## New behavior

Starting in .NET 9, container images no longer install `zlib`. In addition, `zlib` is no longer updated in images where it's already installed from the base image.

## Version introduced

.NET 9 Preview 7

## Type of change

This change is a [behavioral change](../../categories.md#behavioral-change).

## Reason for change

In .NET 9, the Runtime contains a statically linked version of `zlib-ng`. As a result, the .NET Runtime no longer has a package dependency on `zlib`. To reduce .NET container image sizes, .NET 9 container images no longer install `zlib`, and no longer update `zlib` in images where it's already installed from the base Linux image.

## Recommended action

For most scenarios, no action is required. If your containerized .NET app has a direct package dependency on `zlib`, you should manually install it in your Dockerfile using the package manager.

## Affected APIs

None.

## See also
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The `AppContext` switch `System.IO.UseNet5CompatFileStream` and the ability to u

## Previous behavior

The legacy `FileStream` implementation was available and you could opt into it by using the `UseNet5CompatFileStream` switch or the `DOTNET_SYSTEM_IO_USENET5COMPATFILESTREAM` environment variable.
The legacy `FileStream` implementation was available and you could opt in to it by using the `UseNet5CompatFileStream` switch or the `DOTNET_SYSTEM_IO_USENET5COMPATFILESTREAM` environment variable.

## New behavior

Expand All @@ -29,7 +29,7 @@ The `UseNet5CompatFileStream` switch and `DOTNET_SYSTEM_IO_USENET5COMPATFILESTRE

## Recommended action

If you're currently using the switch (or the `DOTNET_SYSTEM_IO_USENET5COMPATFILESTREAM` environment variable) to opt into legacy code and are upgrading to .NET 7, the switch will no longer have any effect and you should remove it.
If you're currently using the switch (or the `DOTNET_SYSTEM_IO_USENET5COMPATFILESTREAM` environment variable) to opt in to legacy code and are upgrading to .NET 7, the switch will no longer have any effect and you should remove it.

## Affected APIs

Expand Down
Loading
Loading