Skip to content
Closed
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
78 changes: 78 additions & 0 deletions sdk/loadtestservice/Azure.Developer.LoadTesting/MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Migration to @azure-typespec/http-client-csharp Generator

This document tracks the migration of Azure.Developer.LoadTesting from the old Autorest generator to the new @azure-typespec/http-client-csharp generator.

## Status: COMPLETED - Code Regeneration

The SDK has been successfully regenerated using the new @azure-typespec/http-client-csharp generator which uses Azure.Core (not System.ClientModel).

### Completed Steps

1. ✅ Updated `tsp-location.yaml` to reference `eng/azure-typespec-http-client-csharp-emitter-package.json`
2. ✅ Regenerated SDK code using the new @azure-typespec/http-client-csharp generator
3. ✅ Verified namespace is correct (Azure.Developer.LoadTesting)
4. ✅ Removed redundant custom pagination methods (now generated)
5. ✅ Updated csproj to maintain Azure.Core compatibility

### Generated Code Quality

The new generator produces:
- ✅ Correct Azure.Core-based clients using `TokenCredential`
- ✅ Proper pagination with `Pageable<T>` / `AsyncPageable<T>`
- ✅ All CRUD operations for tests, test runs, and profiles
- ✅ Metrics and monitoring capabilities
- ✅ Proper model serialization/deserialization

### Remaining Custom Functionality

The following custom classes need to be preserved or rewritten:

1. **FileUploadResultOperation.cs** - Custom LRO for file uploads with validation polling
- Provides `WaitUntil` support
- Polls file validation status

2. **TestRunResultOperation.cs** - Custom LRO for test run execution
- Provides `WaitUntil` support
- Polls test run completion status

3. **TestProfileRunResultOperation.cs** - Custom LRO for profile run execution
- Provides `WaitUntil` support
- Polls profile run completion status

4. **LoadTestAdministrationClient.cs** - Custom wrapper methods
- `UploadTestFile` with LRO support

5. **LoadTestRunClient.cs** - Custom wrapper methods
- `BeginTestRun` with LRO support
- `BeginTestProfileRun` with LRO support

### API Compatibility

The generated API has changed:
- Constructor takes `TokenCredential` (from Azure.Identity) instead of endpoint string
- Some method signatures differ slightly (parameter names, order)
- Custom LRO methods not auto-generated

**Recommendations:**
- These are **breaking changes**
- Plan for a major version bump (2.0.0)
- Provide migration guide for customers
- Custom LRO classes are legitimate value-add and should be retained

### Build Status

- Generated code compiles successfully
- API compatibility checks fail (expected due to breaking changes)
- Custom LRO methods need to be added back

### Next Steps

1. Restore custom LRO operation classes
2. Add custom wrapper methods for UploadTestFile and BeginTestRun
3. Update API compatibility baseline for 2.0.0
4. Update tests and samples
5. Create customer migration guide

### Key Difference from Previous Attempt

The correct emitter `@azure-typespec/http-client-csharp` (via `eng/azure-typespec-http-client-csharp-emitter-package.json`) generates Azure.Core-based clients, not System.ClientModel-based clients. This is the right generator for Azure SDKs and maintains compatibility with the Azure SDK ecosystem.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<IncludeOperationsSharedSource>true</IncludeOperationsSharedSource>
<NoWarn>$(NoWarn);AZC0034</NoWarn>
<IncludeAutorestDependency>true</IncludeAutorestDependency>
<AotCompatOptOut>true</AotCompatOptOut>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using Azure.Core;

namespace Azure.Developer.LoadTesting
{
public partial class LoadTestAdministrationClient
{
/// <summary> Initializes a new instance of LoadTestAdministrationClient. </summary>
/// <param name="endpoint"> The <see cref="Uri"/> to use. </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception>
public LoadTestAdministrationClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new LoadTestingClientOptions())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot we will have to use a similar customization for the client builder extensions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot actually I would have expected the extensions to respect the customization to the ctor. Did we regenerate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added custom client builder extensions with Uri endpoint in commit 5366365. The custom extensions call the Uri-based constructors for backward compatibility, matching the old behavior. The generated extensions use string endpoints, while the custom ones use Uri.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot we shouldn't need to add the custom client builder extensions. I think the custom constructors should be sufficient. Did you try to regenerate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed custom builder extensions in commit 78ae054. The custom Uri constructors are sufficient for backward compatibility on direct instantiation. The generated builder extensions use string endpoints, which is a breaking change from the old Uri-based builder extensions, but the constructors maintain compatibility.

{
}

/// <summary> Initializes a new instance of LoadTestAdministrationClient. </summary>
/// <param name="endpoint"> The <see cref="Uri"/> to use. </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <param name="options"> The options for configuring the client. </param>
/// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception>
public LoadTestAdministrationClient(Uri endpoint, TokenCredential credential, LoadTestingClientOptions options)
: this(endpoint?.Host, credential, options)
{
Argument.AssertNotNull(endpoint, nameof(endpoint));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using Azure.Core;

namespace Azure.Developer.LoadTesting
{
public partial class LoadTestRunClient
{
/// <summary> Initializes a new instance of LoadTestRunClient. </summary>
/// <param name="endpoint"> The <see cref="Uri"/> to use. </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception>
public LoadTestRunClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new LoadTestingClientOptions())
{
}

/// <summary> Initializes a new instance of LoadTestRunClient. </summary>
/// <param name="endpoint"> The <see cref="Uri"/> to use. </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <param name="options"> The options for configuring the client. </param>
/// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception>
public LoadTestRunClient(Uri endpoint, TokenCredential credential, LoadTestingClientOptions options)
: this(endpoint?.Host, credential, options)
{
Argument.AssertNotNull(endpoint, nameof(endpoint));
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading