From a509f6f2cb37386526bcbb1189c4b1bb8c3690e3 Mon Sep 17 00:00:00 2001 From: Arthur Ma Date: Mon, 17 Jun 2024 18:47:48 +0800 Subject: [PATCH] Fixed issue https://github.com/Azure/azure-sdk-for-net/issues/44501 (#44573) --- .../CHANGELOG.md | 8 +- ...Manager.ContainerService.netstandard2.0.cs | 8 - .../assets.json | 2 +- .../Sample_AgentPoolSnapshotCollection.cs | 204 ++ .../Sample_AgentPoolSnapshotResource.cs | 148 + .../Sample_AgentPoolUpgradeProfileResource.cs | 49 + ...ple_ContainerServiceAgentPoolCollection.cs | 1067 ++++++ ...ample_ContainerServiceAgentPoolResource.cs | 983 ++++++ ...rviceMaintenanceConfigurationCollection.cs | 419 +++ ...ServiceMaintenanceConfigurationResource.cs | 241 ++ ...ontainerServiceManagedClusterCollection.cs | 2858 +++++++++++++++++ ..._ContainerServiceManagedClusterResource.cs | 665 ++++ ...vicePrivateEndpointConnectionCollection.cs | 207 ++ ...ervicePrivateEndpointConnectionResource.cs | 118 + ...rviceTrustedAccessRoleBindingCollection.cs | 203 ++ ...ServiceTrustedAccessRoleBindingResource.cs | 114 + ...le_ManagedClusterUpgradeProfileResource.cs | 48 + .../Sample_MeshRevisionProfileCollection.cs | 160 + .../Sample_MeshRevisionProfileResource.cs | 48 + .../Sample_MeshUpgradeProfileCollection.cs | 163 + .../Sample_MeshUpgradeProfileResource.cs | 49 + .../Samples/Sample_OSOptionProfileResource.cs | 47 + .../Sample_SubscriptionResourceExtensions.cs | 74 + .../src/ApiCompatBaseline.txt | 9 + ...re.ResourceManager.ContainerService.csproj | 2 +- .../ContainerServiceAgentPoolResource.cs | 76 - .../ContainerServiceAgentPoolCollection.cs | 4 +- .../ContainerServiceAgentPoolResource.cs | 92 +- ...ontainerServiceManagedClusterCollection.cs | 4 +- .../ContainerServiceManagedClusterResource.cs | 24 +- ...ervicePrivateEndpointConnectionResource.cs | 4 +- .../src/autorest.md | 18 +- .../tests/ContainerServiceAgentPoolTests.cs | 65 + .../tests/ContainerServiceCollectionTests.cs | 4 - 34 files changed, 8052 insertions(+), 133 deletions(-) create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotCollection.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotResource.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolUpgradeProfileResource.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolCollection.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolResource.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationCollection.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationResource.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterCollection.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterResource.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionCollection.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionResource.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingCollection.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingResource.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ManagedClusterUpgradeProfileResource.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshRevisionProfileCollection.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshRevisionProfileResource.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshUpgradeProfileCollection.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshUpgradeProfileResource.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_OSOptionProfileResource.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/src/ApiCompatBaseline.txt create mode 100644 sdk/containerservice/Azure.ResourceManager.ContainerService/tests/ContainerServiceAgentPoolTests.cs diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/CHANGELOG.md b/sdk/containerservice/Azure.ResourceManager.ContainerService/CHANGELOG.md index c9c667b96cef..e047dd0433e3 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/CHANGELOG.md +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 1.3.0-beta.1 (Unreleased) - -### Features Added - -### Breaking Changes +## 1.2.2 (2024-06-17) ### Bugs Fixed -### Other Changes +- Fixed issue https://github.com/Azure/azure-sdk-for-net/issues/44501. ## 1.2.1 (2024-04-29) diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/api/Azure.ResourceManager.ContainerService.netstandard2.0.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/api/Azure.ResourceManager.ContainerService.netstandard2.0.cs index 78b5ad887a20..e571dd7312f7 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/api/Azure.ResourceManager.ContainerService.netstandard2.0.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/api/Azure.ResourceManager.ContainerService.netstandard2.0.cs @@ -169,17 +169,9 @@ protected ContainerServiceAgentPoolResource() { } public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string resourceName, string agentPoolName) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - [System.ObsoleteAttribute("This method is obsolete and will be removed in a future release", false)] public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, bool? ignorePodDisruptionBudget, System.Threading.CancellationToken cancellationToken) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - [System.ObsoleteAttribute("This method is obsolete and will be removed in a future release", false)] public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - [System.ObsoleteAttribute("This method is obsolete and will be removed in a future release", false)] public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, bool? ignorePodDisruptionBudget, System.Threading.CancellationToken cancellationToken) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - [System.ObsoleteAttribute("This method is obsolete and will be removed in a future release", false)] public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ContainerService.AgentPoolUpgradeProfileResource GetAgentPoolUpgradeProfile() { throw null; } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/assets.json b/sdk/containerservice/Azure.ResourceManager.ContainerService/assets.json index a5ffdd8f2065..29e90e5b13d7 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/assets.json +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/containerservice/Azure.ResourceManager.ContainerService", - "Tag": "net/containerservice/Azure.ResourceManager.ContainerService_c9c8b5904c" + "Tag": "net/containerservice/Azure.ResourceManager.ContainerService_e23b32e72d" } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotCollection.cs new file mode 100644 index 000000000000..63175e8ef93c --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotCollection.cs @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_AgentPoolSnapshotCollection + { + // List Snapshots by Resource Group + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListSnapshotsByResourceGroup() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsListByResourceGroup.json + // this example is just showing the usage of "Snapshots_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AgentPoolSnapshotResource + AgentPoolSnapshotCollection collection = resourceGroupResource.GetAgentPoolSnapshots(); + + // invoke the operation and iterate over the result + await foreach (AgentPoolSnapshotResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolSnapshotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get Snapshot + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetSnapshot() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsGet.json + // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AgentPoolSnapshotResource + AgentPoolSnapshotCollection collection = resourceGroupResource.GetAgentPoolSnapshots(); + + // invoke the operation + string resourceName = "snapshot1"; + AgentPoolSnapshotResource result = await collection.GetAsync(resourceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get Snapshot + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetSnapshot() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsGet.json + // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AgentPoolSnapshotResource + AgentPoolSnapshotCollection collection = resourceGroupResource.GetAgentPoolSnapshots(); + + // invoke the operation + string resourceName = "snapshot1"; + bool result = await collection.ExistsAsync(resourceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get Snapshot + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetSnapshot() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsGet.json + // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AgentPoolSnapshotResource + AgentPoolSnapshotCollection collection = resourceGroupResource.GetAgentPoolSnapshots(); + + // invoke the operation + string resourceName = "snapshot1"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + AgentPoolSnapshotResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // Create/Update Snapshot + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateUpdateSnapshot() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsCreate.json + // this example is just showing the usage of "Snapshots_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AgentPoolSnapshotResource + AgentPoolSnapshotCollection collection = resourceGroupResource.GetAgentPoolSnapshots(); + + // invoke the operation + string resourceName = "snapshot1"; + AgentPoolSnapshotData data = new AgentPoolSnapshotData(new AzureLocation("westus")) + { + CreationDataSourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster1/agentPools/pool0"), + Tags = +{ +["key1"] = "val1", +["key2"] = "val2", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + AgentPoolSnapshotResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotResource.cs new file mode 100644 index 000000000000..85da91d3b4d9 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotResource.cs @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerService.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_AgentPoolSnapshotResource + { + // List Snapshots + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAgentPoolSnapshots_ListSnapshots() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsList.json + // this example is just showing the usage of "Snapshots_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AgentPoolSnapshotResource item in subscriptionResource.GetAgentPoolSnapshotsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolSnapshotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get Snapshot + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetSnapshot() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsGet.json + // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AgentPoolSnapshotResource created on azure + // for more information of creating AgentPoolSnapshotResource, please refer to the document of AgentPoolSnapshotResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "snapshot1"; + ResourceIdentifier agentPoolSnapshotResourceId = AgentPoolSnapshotResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + AgentPoolSnapshotResource agentPoolSnapshot = client.GetAgentPoolSnapshotResource(agentPoolSnapshotResourceId); + + // invoke the operation + AgentPoolSnapshotResource result = await agentPoolSnapshot.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Update Snapshot Tags + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateSnapshotTags() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsUpdateTags.json + // this example is just showing the usage of "Snapshots_UpdateTags" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AgentPoolSnapshotResource created on azure + // for more information of creating AgentPoolSnapshotResource, please refer to the document of AgentPoolSnapshotResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "snapshot1"; + ResourceIdentifier agentPoolSnapshotResourceId = AgentPoolSnapshotResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + AgentPoolSnapshotResource agentPoolSnapshot = client.GetAgentPoolSnapshotResource(agentPoolSnapshotResourceId); + + // invoke the operation + ContainerServiceTagsObject containerServiceTagsObject = new ContainerServiceTagsObject() + { + Tags = +{ +["key2"] = "new-val2", +["key3"] = "val3", +}, + }; + AgentPoolSnapshotResource result = await agentPoolSnapshot.UpdateAsync(containerServiceTagsObject); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Delete Snapshot + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteSnapshot() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsDelete.json + // this example is just showing the usage of "Snapshots_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AgentPoolSnapshotResource created on azure + // for more information of creating AgentPoolSnapshotResource, please refer to the document of AgentPoolSnapshotResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "snapshot1"; + ResourceIdentifier agentPoolSnapshotResourceId = AgentPoolSnapshotResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + AgentPoolSnapshotResource agentPoolSnapshot = client.GetAgentPoolSnapshotResource(agentPoolSnapshotResourceId); + + // invoke the operation + await agentPoolSnapshot.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolUpgradeProfileResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolUpgradeProfileResource.cs new file mode 100644 index 000000000000..51a85ec9943c --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolUpgradeProfileResource.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_AgentPoolUpgradeProfileResource + { + // Get Upgrade Profile for Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetUpgradeProfileForAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGetUpgradeProfile.json + // this example is just showing the usage of "AgentPools_GetUpgradeProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AgentPoolUpgradeProfileResource created on azure + // for more information of creating AgentPoolUpgradeProfileResource, please refer to the document of AgentPoolUpgradeProfileResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier agentPoolUpgradeProfileResourceId = AgentPoolUpgradeProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + AgentPoolUpgradeProfileResource agentPoolUpgradeProfile = client.GetAgentPoolUpgradeProfileResource(agentPoolUpgradeProfileResourceId); + + // invoke the operation + AgentPoolUpgradeProfileResource result = await agentPoolUpgradeProfile.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolUpgradeProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolCollection.cs new file mode 100644 index 000000000000..7b21e704d8cc --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolCollection.cs @@ -0,0 +1,1067 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerService.Models; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_ContainerServiceAgentPoolCollection + { + // List Agent Pools by Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListAgentPoolsByManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsList.json + // this example is just showing the usage of "AgentPools_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation and iterate over the result + await foreach (ContainerServiceAgentPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGet.json + // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolResource result = await collection.GetAsync(agentPoolName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGet.json + // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + bool result = await collection.ExistsAsync(agentPoolName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGet.json + // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + NullableResponse response = await collection.GetIfExistsAsync(agentPoolName); + ContainerServiceAgentPoolResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // Create Agent Pool using an agent pool snapshot + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolUsingAnAgentPoolSnapshot() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_Snapshot.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + EnableFips = true, + CreationDataSourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with Capacity Reservation Group + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolWithCapacityReservationGroup() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_CRG.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + CapacityReservationGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/CapacityReservationGroups/crg1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with Dedicated Host Group + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolWithDedicatedHostGroup() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_DedicatedHostGroup.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + HostGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with EncryptionAtHost enabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolWithEncryptionAtHostEnabled() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_EnableEncryptionAtHost.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + EnableEncryptionAtHost = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with Ephemeral OS Disk + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolWithEphemeralOSDisk() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_Ephemeral.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSDiskSizeInGB = 64, + OSDiskType = ContainerServiceOSDiskType.Ephemeral, + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with FIPS enabled OS + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolWithFIPSEnabledOS() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_EnableFIPS.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + EnableFips = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with GPUMIG + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolWithGPUMIG() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_GPUMIG.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_ND96asr_v4", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + KubeletConfig = new KubeletConfig() + { + CpuManagerPolicy = "static", + IsCpuCfsQuotaEnabled = true, + CpuCfsQuotaPeriod = "200ms", + ImageGcHighThreshold = 90, + ImageGcLowThreshold = 70, + TopologyManagerPolicy = "best-effort", + AllowedUnsafeSysctls = +{ +"kernel.msg*","net.core.somaxconn" +}, + FailStartWithSwapOn = false, + }, + LinuxOSConfig = new LinuxOSConfig() + { + Sysctls = new SysctlConfig() + { + NetCoreWmemDefault = 12345, + NetIPv4TcpTwReuse = true, + NetIPv4IPLocalPortRange = "20000 60000", + KernelThreadsMax = 99999, + }, + TransparentHugePageEnabled = "always", + TransparentHugePageDefrag = "madvise", + SwapFileSizeInMB = 1500, + }, + GpuInstanceProfile = GpuInstanceProfile.Mig2G, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with Krustlet and the WASI runtime + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolWithKrustletAndTheWASIRuntime() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_WasmWasi.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSDiskSizeInGB = 64, + WorkloadRuntime = WorkloadRuntime.WasmWasi, + OSType = ContainerServiceOSType.Linux, + Mode = AgentPoolMode.User, + OrchestratorVersion = "", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with KubeletConfig and LinuxOSConfig + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolWithKubeletConfigAndLinuxOSConfig() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_CustomNodeConfig.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + KubeletConfig = new KubeletConfig() + { + CpuManagerPolicy = "static", + IsCpuCfsQuotaEnabled = true, + CpuCfsQuotaPeriod = "200ms", + ImageGcHighThreshold = 90, + ImageGcLowThreshold = 70, + TopologyManagerPolicy = "best-effort", + AllowedUnsafeSysctls = +{ +"kernel.msg*","net.core.somaxconn" +}, + FailStartWithSwapOn = false, + }, + LinuxOSConfig = new LinuxOSConfig() + { + Sysctls = new SysctlConfig() + { + NetCoreWmemDefault = 12345, + NetIPv4TcpTwReuse = true, + NetIPv4IPLocalPortRange = "20000 60000", + KernelThreadsMax = 99999, + }, + TransparentHugePageEnabled = "always", + TransparentHugePageDefrag = "madvise", + SwapFileSizeInMB = 1500, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with OSSKU + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolWithOSSKU() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_OSSKU.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OSSku = ContainerServiceOSSku.AzureLinux, + OrchestratorVersion = "", + KubeletConfig = new KubeletConfig() + { + CpuManagerPolicy = "static", + IsCpuCfsQuotaEnabled = true, + CpuCfsQuotaPeriod = "200ms", + ImageGcHighThreshold = 90, + ImageGcLowThreshold = 70, + TopologyManagerPolicy = "best-effort", + AllowedUnsafeSysctls = +{ +"kernel.msg*","net.core.somaxconn" +}, + FailStartWithSwapOn = false, + }, + LinuxOSConfig = new LinuxOSConfig() + { + Sysctls = new SysctlConfig() + { + NetCoreWmemDefault = 12345, + NetIPv4TcpTwReuse = true, + NetIPv4IPLocalPortRange = "20000 60000", + KernelThreadsMax = 99999, + }, + TransparentHugePageEnabled = "always", + TransparentHugePageDefrag = "madvise", + SwapFileSizeInMB = 1500, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with PPG + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolWithPPG() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_PPG.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with UltraSSD enabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolWithUltraSSDEnabled() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_EnableUltraSSD.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + EnableUltraSsd = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with Windows OSSKU + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAgentPoolWithWindowsOSSKU() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_WindowsOSSKU.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "wnp2"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_D4s_v3", + OSType = ContainerServiceOSType.Windows, + OSSku = ContainerServiceOSSku.Windows2022, + OrchestratorVersion = "1.23.3", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Spot Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateSpotAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_Spot.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS1_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + ScaleSetPriority = ScaleSetPriority.Spot, + ScaleSetEvictionPolicy = ScaleSetEvictionPolicy.Delete, + Tags = +{ +["name1"] = "val1", +}, + NodeLabels = +{ +["key1"] = "val1", +}, + NodeTaints = +{ +"Key1=Value1:NoSchedule" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create/Update Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateUpdateAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_Update.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS1_v2", + OSType = ContainerServiceOSType.Linux, + Mode = AgentPoolMode.User, + OrchestratorVersion = "", + ScaleSetPriority = ScaleSetPriority.Spot, + ScaleSetEvictionPolicy = ScaleSetEvictionPolicy.Delete, + Tags = +{ +["name1"] = "val1", +}, + NodeLabels = +{ +["key1"] = "val1", +}, + NodeTaints = +{ +"Key1=Value1:NoSchedule" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Start Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_StartAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPools_Start.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + PowerStateCode = ContainerServiceStateCode.Running, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Stop Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_StopAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPools_Stop.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + PowerStateCode = ContainerServiceStateCode.Stopped, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Update Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_UpdateAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPools_Update.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS1_v2", + OSType = ContainerServiceOSType.Linux, + MaxCount = 2, + MinCount = 2, + EnableAutoScaling = true, + OrchestratorVersion = "", + ScaleSetPriority = ScaleSetPriority.Spot, + ScaleSetEvictionPolicy = ScaleSetEvictionPolicy.Delete, + NodeTaints = +{ +"Key1=Value1:NoSchedule" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolResource.cs new file mode 100644 index 000000000000..7f4a5fba28b0 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolResource.cs @@ -0,0 +1,983 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerService.Models; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_ContainerServiceAgentPoolResource + { + // Abort operation on agent pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task AbortLatestOperation_AbortOperationOnAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsAbortOperation.json + // this example is just showing the usage of "AgentPools_AbortLatestOperation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + await containerServiceAgentPool.AbortLatestOperationAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Get Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGet.json + // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolResource result = await containerServiceAgentPool.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool using an agent pool snapshot + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolUsingAnAgentPoolSnapshot() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_Snapshot.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + EnableFips = true, + CreationDataSourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"), + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with Capacity Reservation Group + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolWithCapacityReservationGroup() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_CRG.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + CapacityReservationGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/CapacityReservationGroups/crg1"), + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with Dedicated Host Group + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolWithDedicatedHostGroup() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_DedicatedHostGroup.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + HostGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"), + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with EncryptionAtHost enabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolWithEncryptionAtHostEnabled() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_EnableEncryptionAtHost.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + EnableEncryptionAtHost = true, + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with Ephemeral OS Disk + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolWithEphemeralOSDisk() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_Ephemeral.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSDiskSizeInGB = 64, + OSDiskType = ContainerServiceOSDiskType.Ephemeral, + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with FIPS enabled OS + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolWithFIPSEnabledOS() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_EnableFIPS.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + EnableFips = true, + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with GPUMIG + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolWithGPUMIG() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_GPUMIG.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_ND96asr_v4", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + KubeletConfig = new KubeletConfig() + { + CpuManagerPolicy = "static", + IsCpuCfsQuotaEnabled = true, + CpuCfsQuotaPeriod = "200ms", + ImageGcHighThreshold = 90, + ImageGcLowThreshold = 70, + TopologyManagerPolicy = "best-effort", + AllowedUnsafeSysctls = +{ +"kernel.msg*","net.core.somaxconn" +}, + FailStartWithSwapOn = false, + }, + LinuxOSConfig = new LinuxOSConfig() + { + Sysctls = new SysctlConfig() + { + NetCoreWmemDefault = 12345, + NetIPv4TcpTwReuse = true, + NetIPv4IPLocalPortRange = "20000 60000", + KernelThreadsMax = 99999, + }, + TransparentHugePageEnabled = "always", + TransparentHugePageDefrag = "madvise", + SwapFileSizeInMB = 1500, + }, + GpuInstanceProfile = GpuInstanceProfile.Mig2G, + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with Krustlet and the WASI runtime + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolWithKrustletAndTheWASIRuntime() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_WasmWasi.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSDiskSizeInGB = 64, + WorkloadRuntime = WorkloadRuntime.WasmWasi, + OSType = ContainerServiceOSType.Linux, + Mode = AgentPoolMode.User, + OrchestratorVersion = "", + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with KubeletConfig and LinuxOSConfig + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolWithKubeletConfigAndLinuxOSConfig() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_CustomNodeConfig.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + KubeletConfig = new KubeletConfig() + { + CpuManagerPolicy = "static", + IsCpuCfsQuotaEnabled = true, + CpuCfsQuotaPeriod = "200ms", + ImageGcHighThreshold = 90, + ImageGcLowThreshold = 70, + TopologyManagerPolicy = "best-effort", + AllowedUnsafeSysctls = +{ +"kernel.msg*","net.core.somaxconn" +}, + FailStartWithSwapOn = false, + }, + LinuxOSConfig = new LinuxOSConfig() + { + Sysctls = new SysctlConfig() + { + NetCoreWmemDefault = 12345, + NetIPv4TcpTwReuse = true, + NetIPv4IPLocalPortRange = "20000 60000", + KernelThreadsMax = 99999, + }, + TransparentHugePageEnabled = "always", + TransparentHugePageDefrag = "madvise", + SwapFileSizeInMB = 1500, + }, + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with OSSKU + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolWithOSSKU() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_OSSKU.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OSSku = ContainerServiceOSSku.AzureLinux, + OrchestratorVersion = "", + KubeletConfig = new KubeletConfig() + { + CpuManagerPolicy = "static", + IsCpuCfsQuotaEnabled = true, + CpuCfsQuotaPeriod = "200ms", + ImageGcHighThreshold = 90, + ImageGcLowThreshold = 70, + TopologyManagerPolicy = "best-effort", + AllowedUnsafeSysctls = +{ +"kernel.msg*","net.core.somaxconn" +}, + FailStartWithSwapOn = false, + }, + LinuxOSConfig = new LinuxOSConfig() + { + Sysctls = new SysctlConfig() + { + NetCoreWmemDefault = 12345, + NetIPv4TcpTwReuse = true, + NetIPv4IPLocalPortRange = "20000 60000", + KernelThreadsMax = 99999, + }, + TransparentHugePageEnabled = "always", + TransparentHugePageDefrag = "madvise", + SwapFileSizeInMB = 1500, + }, + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with PPG + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolWithPPG() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_PPG.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"), + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with UltraSSD enabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolWithUltraSSDEnabled() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_EnableUltraSSD.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + EnableUltraSsd = true, + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Agent Pool with Windows OSSKU + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAgentPoolWithWindowsOSSKU() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_WindowsOSSKU.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "wnp2"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_D4s_v3", + OSType = ContainerServiceOSType.Windows, + OSSku = ContainerServiceOSSku.Windows2022, + OrchestratorVersion = "1.23.3", + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Spot Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateSpotAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_Spot.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS1_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + ScaleSetPriority = ScaleSetPriority.Spot, + ScaleSetEvictionPolicy = ScaleSetEvictionPolicy.Delete, + Tags = +{ +["name1"] = "val1", +}, + NodeLabels = +{ +["key1"] = "val1", +}, + NodeTaints = +{ +"Key1=Value1:NoSchedule" +}, + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create/Update Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateUpdateAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsCreate_Update.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS1_v2", + OSType = ContainerServiceOSType.Linux, + Mode = AgentPoolMode.User, + OrchestratorVersion = "", + ScaleSetPriority = ScaleSetPriority.Spot, + ScaleSetEvictionPolicy = ScaleSetEvictionPolicy.Delete, + Tags = +{ +["name1"] = "val1", +}, + NodeLabels = +{ +["key1"] = "val1", +}, + NodeTaints = +{ +"Key1=Value1:NoSchedule" +}, + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Start Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_StartAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPools_Start.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + PowerStateCode = ContainerServiceStateCode.Running, + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Stop Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_StopAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPools_Stop.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + PowerStateCode = ContainerServiceStateCode.Stopped, + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Update Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPools_Update.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS1_v2", + OSType = ContainerServiceOSType.Linux, + MaxCount = 2, + MinCount = 2, + EnableAutoScaling = true, + OrchestratorVersion = "", + ScaleSetPriority = ScaleSetPriority.Spot, + ScaleSetEvictionPolicy = ScaleSetEvictionPolicy.Delete, + NodeTaints = +{ +"Key1=Value1:NoSchedule" +}, + }; + ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceAgentPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Delete Agent Pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsDelete.json + // this example is just showing the usage of "AgentPools_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + await containerServiceAgentPool.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Upgrade Agent Pool Node Image Version + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task UpgradeNodeImageVersion_UpgradeAgentPoolNodeImageVersion() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsUpgradeNodeImageVersion.json + // this example is just showing the usage of "AgentPools_UpgradeNodeImageVersion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceAgentPoolResource created on azure + // for more information of creating ContainerServiceAgentPoolResource, please refer to the document of ContainerServiceAgentPoolResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string agentPoolName = "agentpool1"; + ResourceIdentifier containerServiceAgentPoolResourceId = ContainerServiceAgentPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, agentPoolName); + ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); + + // invoke the operation + await containerServiceAgentPool.UpgradeNodeImageVersionAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationCollection.cs new file mode 100644 index 000000000000..519813677639 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationCollection.cs @@ -0,0 +1,419 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerService.Models; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_ContainerServiceMaintenanceConfigurationCollection + { + // List maintenance configurations by Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListMaintenanceConfigurationsByManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsList.json + // this example is just showing the usage of "MaintenanceConfigurations_ListByManagedCluster" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceMaintenanceConfigurationResource + ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); + + // invoke the operation and iterate over the result + await foreach (ContainerServiceMaintenanceConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // List maintenance configurations configured with maintenance window by Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListMaintenanceConfigurationsConfiguredWithMaintenanceWindowByManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsList_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_ListByManagedCluster" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceMaintenanceConfigurationResource + ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); + + // invoke the operation and iterate over the result + await foreach (ContainerServiceMaintenanceConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get Maintenance Configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetMaintenanceConfiguration() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet.json + // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceMaintenanceConfigurationResource + ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); + + // invoke the operation + string configName = "default"; + ContainerServiceMaintenanceConfigurationResource result = await collection.GetAsync(configName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get Maintenance Configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetMaintenanceConfiguration() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet.json + // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceMaintenanceConfigurationResource + ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); + + // invoke the operation + string configName = "default"; + bool result = await collection.ExistsAsync(configName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get Maintenance Configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetMaintenanceConfiguration() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet.json + // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceMaintenanceConfigurationResource + ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); + + // invoke the operation + string configName = "default"; + NullableResponse response = await collection.GetIfExistsAsync(configName); + ContainerServiceMaintenanceConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // Get Maintenance Configuration Configured With Maintenance Window + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetMaintenanceConfigurationConfiguredWithMaintenanceWindow() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceMaintenanceConfigurationResource + ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); + + // invoke the operation + string configName = "aksManagedNodeOSUpgradeSchedule"; + ContainerServiceMaintenanceConfigurationResource result = await collection.GetAsync(configName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get Maintenance Configuration Configured With Maintenance Window + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetMaintenanceConfigurationConfiguredWithMaintenanceWindow() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceMaintenanceConfigurationResource + ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); + + // invoke the operation + string configName = "aksManagedNodeOSUpgradeSchedule"; + bool result = await collection.ExistsAsync(configName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get Maintenance Configuration Configured With Maintenance Window + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetMaintenanceConfigurationConfiguredWithMaintenanceWindow() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceMaintenanceConfigurationResource + ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); + + // invoke the operation + string configName = "aksManagedNodeOSUpgradeSchedule"; + NullableResponse response = await collection.GetIfExistsAsync(configName); + ContainerServiceMaintenanceConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // Create/Update Maintenance Configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateUpdateMaintenanceConfiguration() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsCreate_Update.json + // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceMaintenanceConfigurationResource + ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); + + // invoke the operation + string configName = "default"; + ContainerServiceMaintenanceConfigurationData data = new ContainerServiceMaintenanceConfigurationData() + { + TimesInWeek = +{ +new ContainerServiceTimeInWeek() +{ +Day = ContainerServiceWeekDay.Monday, +HourSlots = +{ +1,2 +}, +} +}, + NotAllowedTimes = +{ +new ContainerServiceTimeSpan() +{ +StartOn = DateTimeOffset.Parse("2020-11-26T03:00:00Z"), +EndOn = DateTimeOffset.Parse("2020-11-30T12:00:00Z"), +} +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configName, data); + ContainerServiceMaintenanceConfigurationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create/Update Maintenance Configuration with Maintenance Window + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateUpdateMaintenanceConfigurationWithMaintenanceWindow() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsCreate_Update_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceMaintenanceConfigurationResource + ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); + + // invoke the operation + string configName = "aksManagedAutoUpgradeSchedule"; + ContainerServiceMaintenanceConfigurationData data = new ContainerServiceMaintenanceConfigurationData() + { + MaintenanceWindow = new ContainerServiceMaintenanceWindow(new ContainerServiceMaintenanceSchedule() + { + RelativeMonthly = new ContainerServiceMaintenanceRelativeMonthlySchedule(3, ContainerServiceMaintenanceRelativeMonthlyScheduleWeekIndex.First, ContainerServiceWeekDay.Monday), + }, 10, "08:30") + { + UtcOffset = "+05:30", + StartDate = "2023-01-01", + NotAllowedDates = +{ +new ContainerServiceDateSpan(DateTimeOffset.Parse("2023-02-18"),DateTimeOffset.Parse("2023-02-25")),new ContainerServiceDateSpan(DateTimeOffset.Parse("2023-12-23"),DateTimeOffset.Parse("2024-01-05")) +}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configName, data); + ContainerServiceMaintenanceConfigurationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationResource.cs new file mode 100644 index 000000000000..e944fd8a1db7 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationResource.cs @@ -0,0 +1,241 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerService.Models; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_ContainerServiceMaintenanceConfigurationResource + { + // Get Maintenance Configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetMaintenanceConfiguration() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet.json + // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceMaintenanceConfigurationResource created on azure + // for more information of creating ContainerServiceMaintenanceConfigurationResource, please refer to the document of ContainerServiceMaintenanceConfigurationResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string configName = "default"; + ResourceIdentifier containerServiceMaintenanceConfigurationResourceId = ContainerServiceMaintenanceConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, configName); + ContainerServiceMaintenanceConfigurationResource containerServiceMaintenanceConfiguration = client.GetContainerServiceMaintenanceConfigurationResource(containerServiceMaintenanceConfigurationResourceId); + + // invoke the operation + ContainerServiceMaintenanceConfigurationResource result = await containerServiceMaintenanceConfiguration.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get Maintenance Configuration Configured With Maintenance Window + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetMaintenanceConfigurationConfiguredWithMaintenanceWindow() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceMaintenanceConfigurationResource created on azure + // for more information of creating ContainerServiceMaintenanceConfigurationResource, please refer to the document of ContainerServiceMaintenanceConfigurationResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string configName = "aksManagedNodeOSUpgradeSchedule"; + ResourceIdentifier containerServiceMaintenanceConfigurationResourceId = ContainerServiceMaintenanceConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, configName); + ContainerServiceMaintenanceConfigurationResource containerServiceMaintenanceConfiguration = client.GetContainerServiceMaintenanceConfigurationResource(containerServiceMaintenanceConfigurationResourceId); + + // invoke the operation + ContainerServiceMaintenanceConfigurationResource result = await containerServiceMaintenanceConfiguration.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create/Update Maintenance Configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateUpdateMaintenanceConfiguration() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsCreate_Update.json + // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceMaintenanceConfigurationResource created on azure + // for more information of creating ContainerServiceMaintenanceConfigurationResource, please refer to the document of ContainerServiceMaintenanceConfigurationResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string configName = "default"; + ResourceIdentifier containerServiceMaintenanceConfigurationResourceId = ContainerServiceMaintenanceConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, configName); + ContainerServiceMaintenanceConfigurationResource containerServiceMaintenanceConfiguration = client.GetContainerServiceMaintenanceConfigurationResource(containerServiceMaintenanceConfigurationResourceId); + + // invoke the operation + ContainerServiceMaintenanceConfigurationData data = new ContainerServiceMaintenanceConfigurationData() + { + TimesInWeek = +{ +new ContainerServiceTimeInWeek() +{ +Day = ContainerServiceWeekDay.Monday, +HourSlots = +{ +1,2 +}, +} +}, + NotAllowedTimes = +{ +new ContainerServiceTimeSpan() +{ +StartOn = DateTimeOffset.Parse("2020-11-26T03:00:00Z"), +EndOn = DateTimeOffset.Parse("2020-11-30T12:00:00Z"), +} +}, + }; + ArmOperation lro = await containerServiceMaintenanceConfiguration.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceMaintenanceConfigurationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create/Update Maintenance Configuration with Maintenance Window + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateUpdateMaintenanceConfigurationWithMaintenanceWindow() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsCreate_Update_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceMaintenanceConfigurationResource created on azure + // for more information of creating ContainerServiceMaintenanceConfigurationResource, please refer to the document of ContainerServiceMaintenanceConfigurationResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string configName = "aksManagedAutoUpgradeSchedule"; + ResourceIdentifier containerServiceMaintenanceConfigurationResourceId = ContainerServiceMaintenanceConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, configName); + ContainerServiceMaintenanceConfigurationResource containerServiceMaintenanceConfiguration = client.GetContainerServiceMaintenanceConfigurationResource(containerServiceMaintenanceConfigurationResourceId); + + // invoke the operation + ContainerServiceMaintenanceConfigurationData data = new ContainerServiceMaintenanceConfigurationData() + { + MaintenanceWindow = new ContainerServiceMaintenanceWindow(new ContainerServiceMaintenanceSchedule() + { + RelativeMonthly = new ContainerServiceMaintenanceRelativeMonthlySchedule(3, ContainerServiceMaintenanceRelativeMonthlyScheduleWeekIndex.First, ContainerServiceWeekDay.Monday), + }, 10, "08:30") + { + UtcOffset = "+05:30", + StartDate = "2023-01-01", + NotAllowedDates = +{ +new ContainerServiceDateSpan(DateTimeOffset.Parse("2023-02-18"),DateTimeOffset.Parse("2023-02-25")),new ContainerServiceDateSpan(DateTimeOffset.Parse("2023-12-23"),DateTimeOffset.Parse("2024-01-05")) +}, + }, + }; + ArmOperation lro = await containerServiceMaintenanceConfiguration.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceMaintenanceConfigurationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Delete Maintenance Configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteMaintenanceConfiguration() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsDelete.json + // this example is just showing the usage of "MaintenanceConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceMaintenanceConfigurationResource created on azure + // for more information of creating ContainerServiceMaintenanceConfigurationResource, please refer to the document of ContainerServiceMaintenanceConfigurationResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string configName = "default"; + ResourceIdentifier containerServiceMaintenanceConfigurationResourceId = ContainerServiceMaintenanceConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, configName); + ContainerServiceMaintenanceConfigurationResource containerServiceMaintenanceConfiguration = client.GetContainerServiceMaintenanceConfigurationResource(containerServiceMaintenanceConfigurationResourceId); + + // invoke the operation + await containerServiceMaintenanceConfiguration.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Delete Maintenance Configuration For Node OS Upgrade + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteMaintenanceConfigurationForNodeOSUpgrade() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsDelete_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceMaintenanceConfigurationResource created on azure + // for more information of creating ContainerServiceMaintenanceConfigurationResource, please refer to the document of ContainerServiceMaintenanceConfigurationResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string configName = "aksManagedNodeOSUpgradeSchedule"; + ResourceIdentifier containerServiceMaintenanceConfigurationResourceId = ContainerServiceMaintenanceConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, configName); + ContainerServiceMaintenanceConfigurationResource containerServiceMaintenanceConfiguration = client.GetContainerServiceMaintenanceConfigurationResource(containerServiceMaintenanceConfigurationResourceId); + + // invoke the operation + await containerServiceMaintenanceConfiguration.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterCollection.cs new file mode 100644 index 000000000000..9a1c4cb74427 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterCollection.cs @@ -0,0 +1,2858 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerService.Models; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_ContainerServiceManagedClusterCollection + { + // Get Managed Clusters by Resource Group + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetManagedClustersByResourceGroup() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersListByResourceGroup.json + // this example is just showing the usage of "ManagedClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation and iterate over the result + await foreach (ContainerServiceManagedClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet.json + // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterResource result = await collection.GetAsync(resourceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet.json + // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + bool result = await collection.ExistsAsync(resourceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet.json + // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + ContainerServiceManagedClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // Create Managed Cluster using an agent pool snapshot + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterUsingAnAgentPoolSnapshot() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_Snapshot.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +EnableFips = true, +CreationDataSourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"), +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = false, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with AKS-managed NAT gateway as outbound type + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithAKSManagedNATGatewayAsOutboundType() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_ManagedNATGateway.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = false, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.ManagedNatGateway, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + NatGatewayProfile = new ManagedClusterNatGatewayProfile() + { + ManagedOutboundIPCount = 2, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with Azure KeyVault Secrets Provider Addon + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithAzureKeyVaultSecretsProviderAddon() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_AzureKeyvaultSecretsProvider.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +["azureKeyvaultSecretsProvider"] = new ManagedClusterAddonProfile(true) +{ +Config = +{ +["enableSecretRotation"] = "true", +["rotationPollInterval"] = "2m", +}, +}, +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with Capacity Reservation Group + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithCapacityReservationGroup() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_CRG.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +CapacityReservationGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/capacityReservationGroups/crg1"), +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with Dedicated Host Group + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithDedicatedHostGroup() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_DedicatedHostGroup.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +EnableNodePublicIP = true, +HostGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"), +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = false, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with EncryptionAtHost enabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithEncryptionAtHostEnabled() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_EnableEncryptionAtHost.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +EnableEncryptionAtHost = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with FIPS enabled OS + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithFIPSEnabledOS() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_EnabledFIPS.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +EnableFips = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = false, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with GPUMIG + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithGPUMIG() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_GPUMIG.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_ND96asr_v4", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +GpuInstanceProfile = GpuInstanceProfile.Mig3G, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + HttpProxyConfig = new ManagedClusterHttpProxyConfig() + { + HttpProxy = "http://myproxy.server.com:8080", + HttpsProxy = "https://myproxy.server.com:8080", + NoProxy = +{ +"localhost","127.0.0.1" +}, + TrustedCA = "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=", + }, + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with HTTP proxy configured + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithHTTPProxyConfigured() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_HTTPProxy.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + HttpProxyConfig = new ManagedClusterHttpProxyConfig() + { + HttpProxy = "http://myproxy.server.com:8080", + HttpsProxy = "https://myproxy.server.com:8080", + NoProxy = +{ +"localhost","127.0.0.1" +}, + TrustedCA = "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=", + }, + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with LongTermSupport + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithLongTermSupport() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_Premium.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = ManagedClusterSkuName.Base, + Tier = ManagedClusterSkuTier.Premium, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +EnableEncryptionAtHost = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + SupportPlan = KubernetesSupportPlan.AKSLongTermSupport, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + ApiServerAccessProfile = new ManagedClusterApiServerAccessProfile() + { + DisableRunCommand = true, + }, + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with Node Public IP Prefix + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithNodePublicIPPrefix() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_NodePublicIPPrefix.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +NodePublicIPPrefixId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Network/publicIPPrefixes/public-ip-prefix"), +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with OSSKU + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithOSSKU() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_OSSKU.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +OSSku = ContainerServiceOSSku.AzureLinux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + HttpProxyConfig = new ManagedClusterHttpProxyConfig() + { + HttpProxy = "http://myproxy.server.com:8080", + HttpsProxy = "https://myproxy.server.com:8080", + NoProxy = +{ +"localhost","127.0.0.1" +}, + TrustedCA = "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=", + }, + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with PPG + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithPPG() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_PPG.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"), +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with PodIdentity enabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithPodIdentityEnabled() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_PodIdentity.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + PodIdentityProfile = new ManagedClusterPodIdentityProfile() + { + IsEnabled = true, + AllowNetworkPluginKubenet = true, + }, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with RunCommand disabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithRunCommandDisabled() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_DisableRunCommand.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +EnableEncryptionAtHost = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + ApiServerAccessProfile = new ManagedClusterApiServerAccessProfile() + { + DisableRunCommand = true, + }, + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with Security Profile configured + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithSecurityProfileConfigured() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_SecurityProfile.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + SecurityProfile = new ManagedClusterSecurityProfile() + { + Defender = new ManagedClusterSecurityProfileDefender() + { + LogAnalyticsWorkspaceResourceId = new ResourceIdentifier("/subscriptions/SUB_ID/resourcegroups/RG_NAME/providers/microsoft.operationalinsights/workspaces/WORKSPACE_NAME"), + IsSecurityMonitoringEnabled = true, + }, + IsWorkloadIdentityEnabled = true, + }, + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with UltraSSD enabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithUltraSSDEnabled() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_EnableUltraSSD.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +EnableUltraSsd = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Cluster with user-assigned NAT gateway as outbound type + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedClusterWithUserAssignedNATGatewayAsOutboundType() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_UserAssignedNATGateway.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = false, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.UserAssignedNatGateway, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Private Cluster with Public FQDN specified + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedPrivateClusterWithPublicFQDNSpecified() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_PrivateClusterPublicFQDN.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +EnableEncryptionAtHost = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + ApiServerAccessProfile = new ManagedClusterApiServerAccessProfile() + { + EnablePrivateCluster = true, + EnablePrivateClusterPublicFqdn = true, + }, + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create Managed Private Cluster with fqdn subdomain specified + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateManagedPrivateClusterWithFqdnSubdomainSpecified() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_PrivateClusterFQDNSubdomain.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + FqdnSubdomain = "domain1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +EnableEncryptionAtHost = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + ApiServerAccessProfile = new ManagedClusterApiServerAccessProfile() + { + EnablePrivateCluster = true, + PrivateDnsZone = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Network/privateDnsZones/privatelink.location1.azmk8s.io", + }, + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create/Update AAD Managed Cluster with EnableAzureRBAC + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateUpdateAADManagedClusterWithEnableAzureRBAC() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_UpdateWithEnableAzureRBAC.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS1_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +AvailabilityZones = +{ +"1","2","3" +}, +EnableNodePublicIP = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AadProfile = new ManagedClusterAadProfile() + { + IsManagedAadEnabled = true, + IsAzureRbacEnabled = true, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create/Update Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateUpdateManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_Update.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + ClusterIdentity = new ManagedClusterIdentity() + { + ResourceIdentityType = "UserAssigned", + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), +}, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS1_v2", +OSType = ContainerServiceOSType.Linux, +ScaleDownMode = ScaleDownMode.Deallocate, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +AvailabilityZones = +{ +"1","2","3" +}, +EnableNodePublicIP = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + UpgradeOverrideSettings = new UpgradeOverrideSettings() + { + ForceUpgrade = false, + Until = DateTimeOffset.Parse("2022-11-01T13:00:00Z"), + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + BalanceSimilarNodeGroups = "true", + Expander = AutoScaleExpander.Priority, + MaxNodeProvisionTime = "15m", + NewPodScaleUpDelay = "1m", + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + SkipNodesWithSystemPods = "false", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create/Update Managed Cluster with Azure Service Mesh + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateUpdateManagedClusterWithAzureServiceMesh() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_AzureServiceMesh.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS2_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +EnableNodePublicIP = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +["azureKeyvaultSecretsProvider"] = new ManagedClusterAddonProfile(true) +{ +Config = +{ +["enableSecretRotation"] = "true", +["rotationPollInterval"] = "2m", +}, +}, +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + ServiceMeshProfile = new ServiceMeshProfile(ServiceMeshMode.Istio) + { + Istio = new IstioServiceMesh() + { + Components = new IstioComponents() + { + IngressGateways = +{ +new IstioIngressGateway(IstioIngressGatewayMode.Internal,true) +}, + EgressGateways = +{ +new IstioEgressGateway(true) +{ +NodeSelector = +{ +["istio"] = "egress", +}, +} +}, + }, + CertificateAuthorityPlugin = new IstioPluginCertificateAuthority() + { + KeyVaultId = new ResourceIdentifier("/subscriptions/854c9ddb-fe9e-4aea-8d58-99ed88282881/resourceGroups/ddama-test/providers/Microsoft.KeyVault/vaults/my-akv"), + CertObjectName = "ca-cert", + KeyObjectName = "ca-key", + RootCertObjectName = "root-cert", + CertChainObjectName = "cert-chain", + }, + }, + }, + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create/Update Managed Cluster with EnableAHUB + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateUpdateManagedClusterWithEnableAHUB() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_UpdateWithAHUB.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + ClusterIdentity = new ManagedClusterIdentity() + { + ResourceIdentityType = "UserAssigned", + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), +}, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS1_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +AvailabilityZones = +{ +"1","2","3" +}, +EnableNodePublicIP = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + LicenseType = WindowsVmLicenseType.WindowsServer, + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create/Update Managed Cluster with Windows gMSA enabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateUpdateManagedClusterWithWindowsGMSAEnabled() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_UpdateWindowsGmsa.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + ClusterIdentity = new ManagedClusterIdentity() + { + ResourceIdentityType = "UserAssigned", + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), +}, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS1_v2", +OSType = ContainerServiceOSType.Linux, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +AvailabilityZones = +{ +"1","2","3" +}, +EnableNodePublicIP = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + GmsaProfile = new WindowsGmsaProfile() + { + IsEnabled = true, + }, + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create/Update Managed Cluster with dual-stack networking + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateUpdateManagedClusterWithDualStackNetworking() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersCreate_DualStackNetworking.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) + { + Sku = new ManagedClusterSku() + { + Name = new ManagedClusterSkuName("Basic"), + Tier = ManagedClusterSkuTier.Free, + }, + ClusterIdentity = new ManagedClusterIdentity() + { + ResourceIdentityType = "UserAssigned", + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), +}, + }, + KubernetesVersion = "", + DnsPrefix = "dnsprefix1", + AgentPoolProfiles = +{ +new ManagedClusterAgentPoolProfile("nodepool1") +{ +Count = 3, +VmSize = "Standard_DS1_v2", +OSType = ContainerServiceOSType.Linux, +ScaleDownMode = ScaleDownMode.Deallocate, +AgentPoolType = AgentPoolType.VirtualMachineScaleSets, +Mode = AgentPoolMode.System, +AvailabilityZones = +{ +"1","2","3" +}, +EnableNodePublicIP = true, +} +}, + LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] + { +new ContainerServiceSshPublicKey("keydata") + })), + WindowsProfile = new ManagedClusterWindowsProfile("azureuser") + { + AdminPassword = "replacePassword1234$", + }, + ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }, + AddonProfiles = +{ +}, + EnableRbac = true, + EnablePodSecurityPolicy = true, + NetworkProfile = new ContainerServiceNetworkProfile() + { + OutboundType = ContainerServiceOutboundType.LoadBalancer, + LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + { + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + { + Count = 2, + }, + }, + IPFamilies = +{ +IPFamily.IPv4,IPFamily.IPv6 +}, + }, + AutoScalerProfile = new ManagedClusterAutoScalerProfile() + { + BalanceSimilarNodeGroups = "true", + Expander = AutoScaleExpander.Priority, + MaxNodeProvisionTime = "15m", + NewPodScaleUpDelay = "1m", + ScanIntervalInSeconds = "20s", + ScaleDownDelayAfterAdd = "15m", + SkipNodesWithSystemPods = "false", + }, + DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), + Tags = +{ +["archv2"] = "", +["tier"] = "production", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterResource.cs new file mode 100644 index 000000000000..268529b0778f --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterResource.cs @@ -0,0 +1,665 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerService.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_ContainerServiceManagedClusterResource + { + // List Managed Clusters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetContainerServiceManagedClusters_ListManagedClusters() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersList.json + // this example is just showing the usage of "ManagedClusters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ContainerServiceManagedClusterResource item in subscriptionResource.GetContainerServiceManagedClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAccessProfile_GetManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGetAccessProfile.json + // this example is just showing the usage of "ManagedClusters_GetAccessProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + string roleName = "clusterUser"; + ManagedClusterAccessProfile result = await containerServiceManagedCluster.GetAccessProfileAsync(roleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetClusterAdminCredentials_GetManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersListClusterAdminCredentials.json + // this example is just showing the usage of "ManagedClusters_ListClusterAdminCredentials" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + ManagedClusterCredentials result = await containerServiceManagedCluster.GetClusterAdminCredentialsAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetClusterUserCredentials_GetManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersListClusterUserCredentials.json + // this example is just showing the usage of "ManagedClusters_ListClusterUserCredentials" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + ManagedClusterCredentials result = await containerServiceManagedCluster.GetClusterUserCredentialsAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetClusterMonitoringUserCredentials_GetManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersListClusterMonitoringUserCredentials.json + // this example is just showing the usage of "ManagedClusters_ListClusterMonitoringUserCredentials" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + ManagedClusterCredentials result = await containerServiceManagedCluster.GetClusterMonitoringUserCredentialsAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet.json + // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + ContainerServiceManagedClusterResource result = await containerServiceManagedCluster.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Update Managed Cluster Tags + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateManagedClusterTags() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersUpdateTags.json + // this example is just showing the usage of "ManagedClusters_UpdateTags" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + ContainerServiceTagsObject containerServiceTagsObject = new ContainerServiceTagsObject() + { + Tags = +{ +["archv3"] = "", +["tier"] = "testing", +}, + }; + ArmOperation lro = await containerServiceManagedCluster.UpdateAsync(WaitUntil.Completed, containerServiceTagsObject); + ContainerServiceManagedClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Delete Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersDelete.json + // this example is just showing the usage of "ManagedClusters_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + await containerServiceManagedCluster.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Reset Service Principal Profile + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task ResetServicePrincipalProfile_ResetServicePrincipalProfile() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersResetServicePrincipalProfile.json + // this example is just showing the usage of "ManagedClusters_ResetServicePrincipalProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + ManagedClusterServicePrincipalProfile managedClusterServicePrincipalProfile = new ManagedClusterServicePrincipalProfile("clientid") + { + Secret = "secret", + }; + await containerServiceManagedCluster.ResetServicePrincipalProfileAsync(WaitUntil.Completed, managedClusterServicePrincipalProfile); + + Console.WriteLine($"Succeeded"); + } + + // Reset AAD Profile + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task ResetAadProfile_ResetAADProfile() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersResetAADProfile.json + // this example is just showing the usage of "ManagedClusters_ResetAadProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + ManagedClusterAadProfile managedClusterAadProfile = new ManagedClusterAadProfile() + { + ClientAppId = Guid.Parse("clientappid"), + ServerAppId = Guid.Parse("serverappid"), + ServerAppSecret = "serverappsecret", + TenantId = Guid.Parse("tenantid"), + }; + await containerServiceManagedCluster.ResetAadProfileAsync(WaitUntil.Completed, managedClusterAadProfile); + + Console.WriteLine($"Succeeded"); + } + + // Rotate Cluster Certificates + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task RotateClusterCertificates_RotateClusterCertificates() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersRotateClusterCertificates.json + // this example is just showing the usage of "ManagedClusters_RotateClusterCertificates" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + await containerServiceManagedCluster.RotateClusterCertificatesAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Abort operation on managed cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task AbortLatestOperation_AbortOperationOnManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersAbortOperation.json + // this example is just showing the usage of "ManagedClusters_AbortLatestOperation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + await containerServiceManagedCluster.AbortLatestOperationAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Rotate Cluster Service Account Signing Keys + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task RotateServiceAccountSigningKeys_RotateClusterServiceAccountSigningKeys() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersRotateServiceAccountSigningKeys.json + // this example is just showing the usage of "ManagedClusters_RotateServiceAccountSigningKeys" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + await containerServiceManagedCluster.RotateServiceAccountSigningKeysAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Stop Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Stop_StopManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersStop.json + // this example is just showing the usage of "ManagedClusters_Stop" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + await containerServiceManagedCluster.StopAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Start Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Start_StartManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersStart.json + // this example is just showing the usage of "ManagedClusters_Start" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + await containerServiceManagedCluster.StartAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // submitNewCommand + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task RunCommand_SubmitNewCommand() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/RunCommandRequest.json + // this example is just showing the usage of "ManagedClusters_RunCommand" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + ManagedClusterRunCommandContent content = new ManagedClusterRunCommandContent("kubectl apply -f ns.yaml") + { + Context = "", + ClusterToken = "", + }; + ArmOperation lro = await containerServiceManagedCluster.RunCommandAsync(WaitUntil.Completed, content); + ManagedClusterRunCommandResult result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + + // commandFailedResult + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetCommandResult_CommandFailedResult() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/RunCommandResultFailed.json + // this example is just showing the usage of "ManagedClusters_GetCommandResult" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + string commandId = "def7b3ea71bd4f7e9d226ddbc0f00ad9"; + ManagedClusterRunCommandResult result = await containerServiceManagedCluster.GetCommandResultAsync(commandId); + + Console.WriteLine($"Succeeded: {result}"); + } + + // commandSucceedResult + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetCommandResult_CommandSucceedResult() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/RunCommandResultSucceed.json + // this example is just showing the usage of "ManagedClusters_GetCommandResult" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + string commandId = "def7b3ea71bd4f7e9d226ddbc0f00ad9"; + ManagedClusterRunCommandResult result = await containerServiceManagedCluster.GetCommandResultAsync(commandId); + + Console.WriteLine($"Succeeded: {result}"); + } + + // List OutboundNetworkDependenciesEndpoints by Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetOutboundNetworkDependenciesEndpoints_ListOutboundNetworkDependenciesEndpointsByManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/OutboundNetworkDependenciesEndpointsList.json + // this example is just showing the usage of "ManagedClusters_ListOutboundNetworkDependenciesEndpoints" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation and iterate over the result + await foreach (ContainerServiceOutboundEnvironmentEndpoint item in containerServiceManagedCluster.GetOutboundNetworkDependenciesEndpointsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get available versions for agent pool + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAvailableAgentPoolVersions_GetAvailableVersionsForAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGetAgentPoolAvailableVersions.json + // this example is just showing the usage of "AgentPools_GetAvailableAgentPoolVersions" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + AgentPoolAvailableVersions result = await containerServiceManagedCluster.GetAvailableAgentPoolVersionsAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + + // List Private Link Resources by Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetPrivateLinkResources_ListPrivateLinkResourcesByManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateLinkResourcesList.json + // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation and iterate over the result + await foreach (ContainerServicePrivateLinkResourceData item in containerServiceManagedCluster.GetPrivateLinkResourcesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Resolve the Private Link Service ID for Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task ResolvePrivateLinkServiceId_ResolveThePrivateLinkServiceIDForManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ResolvePrivateLinkServiceId.json + // this example is just showing the usage of "ResolvePrivateLinkServiceId_Post" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // invoke the operation + ContainerServicePrivateLinkResourceData data = new ContainerServicePrivateLinkResourceData() + { + Name = "management", + }; + ContainerServicePrivateLinkResourceData result = await containerServiceManagedCluster.ResolvePrivateLinkServiceIdAsync(data); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionCollection.cs new file mode 100644 index 000000000000..253453010288 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionCollection.cs @@ -0,0 +1,207 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerService.Models; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_ContainerServicePrivateEndpointConnectionCollection + { + // List Private Endpoint Connections by Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListPrivateEndpointConnectionsByManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsList.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServicePrivateEndpointConnectionResource + ContainerServicePrivateEndpointConnectionCollection collection = containerServiceManagedCluster.GetContainerServicePrivateEndpointConnections(); + + // invoke the operation and iterate over the result + await foreach (ContainerServicePrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServicePrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get Private Endpoint Connection + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetPrivateEndpointConnection() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServicePrivateEndpointConnectionResource + ContainerServicePrivateEndpointConnectionCollection collection = containerServiceManagedCluster.GetContainerServicePrivateEndpointConnections(); + + // invoke the operation + string privateEndpointConnectionName = "privateendpointconnection1"; + ContainerServicePrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServicePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get Private Endpoint Connection + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetPrivateEndpointConnection() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServicePrivateEndpointConnectionResource + ContainerServicePrivateEndpointConnectionCollection collection = containerServiceManagedCluster.GetContainerServicePrivateEndpointConnections(); + + // invoke the operation + string privateEndpointConnectionName = "privateendpointconnection1"; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get Private Endpoint Connection + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetPrivateEndpointConnection() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServicePrivateEndpointConnectionResource + ContainerServicePrivateEndpointConnectionCollection collection = containerServiceManagedCluster.GetContainerServicePrivateEndpointConnections(); + + // invoke the operation + string privateEndpointConnectionName = "privateendpointconnection1"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + ContainerServicePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServicePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // Update Private Endpoint Connection + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_UpdatePrivateEndpointConnection() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServicePrivateEndpointConnectionResource + ContainerServicePrivateEndpointConnectionCollection collection = containerServiceManagedCluster.GetContainerServicePrivateEndpointConnections(); + + // invoke the operation + string privateEndpointConnectionName = "privateendpointconnection1"; + ContainerServicePrivateEndpointConnectionData data = new ContainerServicePrivateEndpointConnectionData() + { + ConnectionState = new ContainerServicePrivateLinkServiceConnectionState() + { + Status = ContainerServicePrivateLinkServiceConnectionStatus.Approved, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + ContainerServicePrivateEndpointConnectionResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServicePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionResource.cs new file mode 100644 index 000000000000..89fceb7048f1 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionResource.cs @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerService.Models; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_ContainerServicePrivateEndpointConnectionResource + { + // Get Private Endpoint Connection + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetPrivateEndpointConnection() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServicePrivateEndpointConnectionResource created on azure + // for more information of creating ContainerServicePrivateEndpointConnectionResource, please refer to the document of ContainerServicePrivateEndpointConnectionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string privateEndpointConnectionName = "privateendpointconnection1"; + ResourceIdentifier containerServicePrivateEndpointConnectionResourceId = ContainerServicePrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, privateEndpointConnectionName); + ContainerServicePrivateEndpointConnectionResource containerServicePrivateEndpointConnection = client.GetContainerServicePrivateEndpointConnectionResource(containerServicePrivateEndpointConnectionResourceId); + + // invoke the operation + ContainerServicePrivateEndpointConnectionResource result = await containerServicePrivateEndpointConnection.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServicePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Update Private Endpoint Connection + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdatePrivateEndpointConnection() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServicePrivateEndpointConnectionResource created on azure + // for more information of creating ContainerServicePrivateEndpointConnectionResource, please refer to the document of ContainerServicePrivateEndpointConnectionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string privateEndpointConnectionName = "privateendpointconnection1"; + ResourceIdentifier containerServicePrivateEndpointConnectionResourceId = ContainerServicePrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, privateEndpointConnectionName); + ContainerServicePrivateEndpointConnectionResource containerServicePrivateEndpointConnection = client.GetContainerServicePrivateEndpointConnectionResource(containerServicePrivateEndpointConnectionResourceId); + + // invoke the operation + ContainerServicePrivateEndpointConnectionData data = new ContainerServicePrivateEndpointConnectionData() + { + ConnectionState = new ContainerServicePrivateLinkServiceConnectionState() + { + Status = ContainerServicePrivateLinkServiceConnectionStatus.Approved, + }, + }; + ArmOperation lro = await containerServicePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ContainerServicePrivateEndpointConnectionResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServicePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Delete Private Endpoint Connection + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeletePrivateEndpointConnection() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsDelete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServicePrivateEndpointConnectionResource created on azure + // for more information of creating ContainerServicePrivateEndpointConnectionResource, please refer to the document of ContainerServicePrivateEndpointConnectionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string privateEndpointConnectionName = "privateendpointconnection1"; + ResourceIdentifier containerServicePrivateEndpointConnectionResourceId = ContainerServicePrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, privateEndpointConnectionName); + ContainerServicePrivateEndpointConnectionResource containerServicePrivateEndpointConnection = client.GetContainerServicePrivateEndpointConnectionResource(containerServicePrivateEndpointConnectionResourceId); + + // invoke the operation + await containerServicePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingCollection.cs new file mode 100644 index 000000000000..bc47c1281cb0 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingCollection.cs @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_ContainerServiceTrustedAccessRoleBindingCollection + { + // List trusted access role bindings + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListTrustedAccessRoleBindings() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_List.json + // this example is just showing the usage of "TrustedAccessRoleBindings_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceTrustedAccessRoleBindingResource + ContainerServiceTrustedAccessRoleBindingCollection collection = containerServiceManagedCluster.GetContainerServiceTrustedAccessRoleBindings(); + + // invoke the operation and iterate over the result + await foreach (ContainerServiceTrustedAccessRoleBindingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceTrustedAccessRoleBindingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get a trusted access role binding + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetATrustedAccessRoleBinding() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_Get.json + // this example is just showing the usage of "TrustedAccessRoleBindings_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceTrustedAccessRoleBindingResource + ContainerServiceTrustedAccessRoleBindingCollection collection = containerServiceManagedCluster.GetContainerServiceTrustedAccessRoleBindings(); + + // invoke the operation + string trustedAccessRoleBindingName = "binding1"; + ContainerServiceTrustedAccessRoleBindingResource result = await collection.GetAsync(trustedAccessRoleBindingName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceTrustedAccessRoleBindingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a trusted access role binding + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetATrustedAccessRoleBinding() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_Get.json + // this example is just showing the usage of "TrustedAccessRoleBindings_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceTrustedAccessRoleBindingResource + ContainerServiceTrustedAccessRoleBindingCollection collection = containerServiceManagedCluster.GetContainerServiceTrustedAccessRoleBindings(); + + // invoke the operation + string trustedAccessRoleBindingName = "binding1"; + bool result = await collection.ExistsAsync(trustedAccessRoleBindingName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get a trusted access role binding + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetATrustedAccessRoleBinding() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_Get.json + // this example is just showing the usage of "TrustedAccessRoleBindings_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceTrustedAccessRoleBindingResource + ContainerServiceTrustedAccessRoleBindingCollection collection = containerServiceManagedCluster.GetContainerServiceTrustedAccessRoleBindings(); + + // invoke the operation + string trustedAccessRoleBindingName = "binding1"; + NullableResponse response = await collection.GetIfExistsAsync(trustedAccessRoleBindingName); + ContainerServiceTrustedAccessRoleBindingResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceTrustedAccessRoleBindingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // Create or update a trusted access role binding + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateOrUpdateATrustedAccessRoleBinding() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_CreateOrUpdate.json + // this example is just showing the usage of "TrustedAccessRoleBindings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceTrustedAccessRoleBindingResource + ContainerServiceTrustedAccessRoleBindingCollection collection = containerServiceManagedCluster.GetContainerServiceTrustedAccessRoleBindings(); + + // invoke the operation + string trustedAccessRoleBindingName = "binding1"; + ContainerServiceTrustedAccessRoleBindingData data = new ContainerServiceTrustedAccessRoleBindingData(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/b/providers/Microsoft.MachineLearningServices/workspaces/c"), new string[] + { +"Microsoft.MachineLearningServices/workspaces/reader","Microsoft.MachineLearningServices/workspaces/writer" + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, trustedAccessRoleBindingName, data); + ContainerServiceTrustedAccessRoleBindingResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceTrustedAccessRoleBindingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingResource.cs new file mode 100644 index 000000000000..71e7ffd14015 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingResource.cs @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_ContainerServiceTrustedAccessRoleBindingResource + { + // Get a trusted access role binding + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetATrustedAccessRoleBinding() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_Get.json + // this example is just showing the usage of "TrustedAccessRoleBindings_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceTrustedAccessRoleBindingResource created on azure + // for more information of creating ContainerServiceTrustedAccessRoleBindingResource, please refer to the document of ContainerServiceTrustedAccessRoleBindingResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string trustedAccessRoleBindingName = "binding1"; + ResourceIdentifier containerServiceTrustedAccessRoleBindingResourceId = ContainerServiceTrustedAccessRoleBindingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, trustedAccessRoleBindingName); + ContainerServiceTrustedAccessRoleBindingResource containerServiceTrustedAccessRoleBinding = client.GetContainerServiceTrustedAccessRoleBindingResource(containerServiceTrustedAccessRoleBindingResourceId); + + // invoke the operation + ContainerServiceTrustedAccessRoleBindingResource result = await containerServiceTrustedAccessRoleBinding.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceTrustedAccessRoleBindingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create or update a trusted access role binding + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateOrUpdateATrustedAccessRoleBinding() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_CreateOrUpdate.json + // this example is just showing the usage of "TrustedAccessRoleBindings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceTrustedAccessRoleBindingResource created on azure + // for more information of creating ContainerServiceTrustedAccessRoleBindingResource, please refer to the document of ContainerServiceTrustedAccessRoleBindingResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string trustedAccessRoleBindingName = "binding1"; + ResourceIdentifier containerServiceTrustedAccessRoleBindingResourceId = ContainerServiceTrustedAccessRoleBindingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, trustedAccessRoleBindingName); + ContainerServiceTrustedAccessRoleBindingResource containerServiceTrustedAccessRoleBinding = client.GetContainerServiceTrustedAccessRoleBindingResource(containerServiceTrustedAccessRoleBindingResourceId); + + // invoke the operation + ContainerServiceTrustedAccessRoleBindingData data = new ContainerServiceTrustedAccessRoleBindingData(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/b/providers/Microsoft.MachineLearningServices/workspaces/c"), new string[] + { +"Microsoft.MachineLearningServices/workspaces/reader","Microsoft.MachineLearningServices/workspaces/writer" + }); + ArmOperation lro = await containerServiceTrustedAccessRoleBinding.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceTrustedAccessRoleBindingResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceTrustedAccessRoleBindingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Delete a trusted access role binding + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteATrustedAccessRoleBinding() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_Delete.json + // this example is just showing the usage of "TrustedAccessRoleBindings_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceTrustedAccessRoleBindingResource created on azure + // for more information of creating ContainerServiceTrustedAccessRoleBindingResource, please refer to the document of ContainerServiceTrustedAccessRoleBindingResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string trustedAccessRoleBindingName = "binding1"; + ResourceIdentifier containerServiceTrustedAccessRoleBindingResourceId = ContainerServiceTrustedAccessRoleBindingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, trustedAccessRoleBindingName); + ContainerServiceTrustedAccessRoleBindingResource containerServiceTrustedAccessRoleBinding = client.GetContainerServiceTrustedAccessRoleBindingResource(containerServiceTrustedAccessRoleBindingResourceId); + + // invoke the operation + await containerServiceTrustedAccessRoleBinding.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ManagedClusterUpgradeProfileResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ManagedClusterUpgradeProfileResource.cs new file mode 100644 index 000000000000..f47c234140f9 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ManagedClusterUpgradeProfileResource.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_ManagedClusterUpgradeProfileResource + { + // Get Upgrade Profile for Managed Cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetUpgradeProfileForManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGetUpgradeProfile.json + // this example is just showing the usage of "ManagedClusters_GetUpgradeProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedClusterUpgradeProfileResource created on azure + // for more information of creating ManagedClusterUpgradeProfileResource, please refer to the document of ManagedClusterUpgradeProfileResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier managedClusterUpgradeProfileResourceId = ManagedClusterUpgradeProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ManagedClusterUpgradeProfileResource managedClusterUpgradeProfile = client.GetManagedClusterUpgradeProfileResource(managedClusterUpgradeProfileResourceId); + + // invoke the operation + ManagedClusterUpgradeProfileResource result = await managedClusterUpgradeProfile.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedClusterUpgradeProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshRevisionProfileCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshRevisionProfileCollection.cs new file mode 100644 index 000000000000..884bd8df18bb --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshRevisionProfileCollection.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_MeshRevisionProfileCollection + { + // List mesh revision profiles in a location + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListMeshRevisionProfilesInALocation() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersList_MeshRevisionProfiles.json + // this example is just showing the usage of "ManagedClusters_ListMeshRevisionProfiles" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this MeshRevisionProfileResource + AzureLocation location = new AzureLocation("location1"); + MeshRevisionProfileCollection collection = subscriptionResource.GetMeshRevisionProfiles(location); + + // invoke the operation and iterate over the result + await foreach (MeshRevisionProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MeshRevisionProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get a mesh revision profile for a mesh mode + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetAMeshRevisionProfileForAMeshMode() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet_MeshRevisionProfile.json + // this example is just showing the usage of "ManagedClusters_GetMeshRevisionProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this MeshRevisionProfileResource + AzureLocation location = new AzureLocation("location1"); + MeshRevisionProfileCollection collection = subscriptionResource.GetMeshRevisionProfiles(location); + + // invoke the operation + string mode = "istio"; + MeshRevisionProfileResource result = await collection.GetAsync(mode); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MeshRevisionProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a mesh revision profile for a mesh mode + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetAMeshRevisionProfileForAMeshMode() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet_MeshRevisionProfile.json + // this example is just showing the usage of "ManagedClusters_GetMeshRevisionProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this MeshRevisionProfileResource + AzureLocation location = new AzureLocation("location1"); + MeshRevisionProfileCollection collection = subscriptionResource.GetMeshRevisionProfiles(location); + + // invoke the operation + string mode = "istio"; + bool result = await collection.ExistsAsync(mode); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get a mesh revision profile for a mesh mode + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetAMeshRevisionProfileForAMeshMode() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet_MeshRevisionProfile.json + // this example is just showing the usage of "ManagedClusters_GetMeshRevisionProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this MeshRevisionProfileResource + AzureLocation location = new AzureLocation("location1"); + MeshRevisionProfileCollection collection = subscriptionResource.GetMeshRevisionProfiles(location); + + // invoke the operation + string mode = "istio"; + NullableResponse response = await collection.GetIfExistsAsync(mode); + MeshRevisionProfileResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MeshRevisionProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshRevisionProfileResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshRevisionProfileResource.cs new file mode 100644 index 000000000000..1f93aa28ed71 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshRevisionProfileResource.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_MeshRevisionProfileResource + { + // Get a mesh revision profile for a mesh mode + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetAMeshRevisionProfileForAMeshMode() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet_MeshRevisionProfile.json + // this example is just showing the usage of "ManagedClusters_GetMeshRevisionProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MeshRevisionProfileResource created on azure + // for more information of creating MeshRevisionProfileResource, please refer to the document of MeshRevisionProfileResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + AzureLocation location = new AzureLocation("location1"); + string mode = "istio"; + ResourceIdentifier meshRevisionProfileResourceId = MeshRevisionProfileResource.CreateResourceIdentifier(subscriptionId, location, mode); + MeshRevisionProfileResource meshRevisionProfile = client.GetMeshRevisionProfileResource(meshRevisionProfileResourceId); + + // invoke the operation + MeshRevisionProfileResource result = await meshRevisionProfile.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MeshRevisionProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshUpgradeProfileCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshUpgradeProfileCollection.cs new file mode 100644 index 000000000000..3cfc385c081e --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshUpgradeProfileCollection.cs @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_MeshUpgradeProfileCollection + { + // Lists version compatibility and upgrade profile for all service meshes in a cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListsVersionCompatibilityAndUpgradeProfileForAllServiceMeshesInACluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersList_MeshUpgradeProfiles.json + // this example is just showing the usage of "ManagedClusters_ListMeshUpgradeProfiles" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this MeshUpgradeProfileResource + MeshUpgradeProfileCollection collection = containerServiceManagedCluster.GetMeshUpgradeProfiles(); + + // invoke the operation and iterate over the result + await foreach (MeshUpgradeProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MeshUpgradeProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Gets version compatibility and upgrade profile for a service mesh in a cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetsVersionCompatibilityAndUpgradeProfileForAServiceMeshInACluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet_MeshUpgradeProfile.json + // this example is just showing the usage of "ManagedClusters_GetMeshUpgradeProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this MeshUpgradeProfileResource + MeshUpgradeProfileCollection collection = containerServiceManagedCluster.GetMeshUpgradeProfiles(); + + // invoke the operation + string mode = "istio"; + MeshUpgradeProfileResource result = await collection.GetAsync(mode); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MeshUpgradeProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Gets version compatibility and upgrade profile for a service mesh in a cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetsVersionCompatibilityAndUpgradeProfileForAServiceMeshInACluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet_MeshUpgradeProfile.json + // this example is just showing the usage of "ManagedClusters_GetMeshUpgradeProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this MeshUpgradeProfileResource + MeshUpgradeProfileCollection collection = containerServiceManagedCluster.GetMeshUpgradeProfiles(); + + // invoke the operation + string mode = "istio"; + bool result = await collection.ExistsAsync(mode); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Gets version compatibility and upgrade profile for a service mesh in a cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetsVersionCompatibilityAndUpgradeProfileForAServiceMeshInACluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet_MeshUpgradeProfile.json + // this example is just showing the usage of "ManagedClusters_GetMeshUpgradeProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this MeshUpgradeProfileResource + MeshUpgradeProfileCollection collection = containerServiceManagedCluster.GetMeshUpgradeProfiles(); + + // invoke the operation + string mode = "istio"; + NullableResponse response = await collection.GetIfExistsAsync(mode); + MeshUpgradeProfileResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MeshUpgradeProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshUpgradeProfileResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshUpgradeProfileResource.cs new file mode 100644 index 000000000000..9d5fb16420aa --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshUpgradeProfileResource.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_MeshUpgradeProfileResource + { + // Gets version compatibility and upgrade profile for a service mesh in a cluster + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetsVersionCompatibilityAndUpgradeProfileForAServiceMeshInACluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet_MeshUpgradeProfile.json + // this example is just showing the usage of "ManagedClusters_GetMeshUpgradeProfile" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MeshUpgradeProfileResource created on azure + // for more information of creating MeshUpgradeProfileResource, please refer to the document of MeshUpgradeProfileResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + string mode = "istio"; + ResourceIdentifier meshUpgradeProfileResourceId = MeshUpgradeProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, mode); + MeshUpgradeProfileResource meshUpgradeProfile = client.GetMeshUpgradeProfileResource(meshUpgradeProfileResourceId); + + // invoke the operation + MeshUpgradeProfileResource result = await meshUpgradeProfile.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MeshUpgradeProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_OSOptionProfileResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_OSOptionProfileResource.cs new file mode 100644 index 000000000000..d523ebe5480a --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_OSOptionProfileResource.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_OSOptionProfileResource + { + // Get Container Service OS Options + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetContainerServiceOSOptions() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ContainerServiceGetOSOptions.json + // this example is just showing the usage of "ManagedClusters_GetOSOptions" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this OSOptionProfileResource created on azure + // for more information of creating OSOptionProfileResource, please refer to the document of OSOptionProfileResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + AzureLocation location = new AzureLocation("location1"); + ResourceIdentifier osOptionProfileResourceId = OSOptionProfileResource.CreateResourceIdentifier(subscriptionId, location); + OSOptionProfileResource osOptionProfile = client.GetOSOptionProfileResource(osOptionProfileResourceId); + + // invoke the operation + OSOptionProfileResource result = await osOptionProfile.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OSOptionProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 000000000000..4ffce8b10134 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerService.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerService.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + // List Kubernetes Versions + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetKubernetesVersionsManagedCluster_ListKubernetesVersions() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/KubernetesVersions_List.json + // this example is just showing the usage of "ManagedClusters_ListKubernetesVersions" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("location1"); + KubernetesVersionListResult result = await subscriptionResource.GetKubernetesVersionsManagedClusterAsync(location); + + Console.WriteLine($"Succeeded: {result}"); + } + + // List trusted access roles + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetTrustedAccessRoles_ListTrustedAccessRoles() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoles_List.json + // this example is just showing the usage of "TrustedAccessRoles_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("westus2"); + await foreach (ContainerServiceTrustedAccessRole item in subscriptionResource.GetTrustedAccessRolesAsync(location)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/ApiCompatBaseline.txt b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/ApiCompatBaseline.txt new file mode 100644 index 000000000000..0174f7742674 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/ApiCompatBaseline.txt @@ -0,0 +1,9 @@ +# Baselining these until the next GA as they are not actual compat issues. +CannotRemoveAttribute : Attribute 'System.ComponentModel.EditorBrowsableAttribute' exists on 'Azure.ResourceManager.ContainerService.ContainerServiceAgentPoolResource.Delete(Azure.WaitUntil, System.Nullable, System.Threading.CancellationToken)' in the contract but not the implementation. +CannotRemoveAttribute : Attribute 'System.ObsoleteAttribute' exists on 'Azure.ResourceManager.ContainerService.ContainerServiceAgentPoolResource.Delete(Azure.WaitUntil, System.Nullable, System.Threading.CancellationToken)' in the contract but not the implementation. +CannotRemoveAttribute : Attribute 'System.ComponentModel.EditorBrowsableAttribute' exists on 'Azure.ResourceManager.ContainerService.ContainerServiceAgentPoolResource.Delete(Azure.WaitUntil, System.Threading.CancellationToken)' in the contract but not the implementation. +CannotRemoveAttribute : Attribute 'System.ObsoleteAttribute' exists on 'Azure.ResourceManager.ContainerService.ContainerServiceAgentPoolResource.Delete(Azure.WaitUntil, System.Threading.CancellationToken)' in the contract but not the implementation. +CannotRemoveAttribute : Attribute 'System.ComponentModel.EditorBrowsableAttribute' exists on 'Azure.ResourceManager.ContainerService.ContainerServiceAgentPoolResource.DeleteAsync(Azure.WaitUntil, System.Nullable, System.Threading.CancellationToken)' in the contract but not the implementation. +CannotRemoveAttribute : Attribute 'System.ObsoleteAttribute' exists on 'Azure.ResourceManager.ContainerService.ContainerServiceAgentPoolResource.DeleteAsync(Azure.WaitUntil, System.Nullable, System.Threading.CancellationToken)' in the contract but not the implementation. +CannotRemoveAttribute : Attribute 'System.ComponentModel.EditorBrowsableAttribute' exists on 'Azure.ResourceManager.ContainerService.ContainerServiceAgentPoolResource.DeleteAsync(Azure.WaitUntil, System.Threading.CancellationToken)' in the contract but not the implementation. +CannotRemoveAttribute : Attribute 'System.ObsoleteAttribute' exists on 'Azure.ResourceManager.ContainerService.ContainerServiceAgentPoolResource.DeleteAsync(Azure.WaitUntil, System.Threading.CancellationToken)' in the contract but not the implementation. \ No newline at end of file diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Azure.ResourceManager.ContainerService.csproj b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Azure.ResourceManager.ContainerService.csproj index 699e27546af1..50b41eb21007 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Azure.ResourceManager.ContainerService.csproj +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Azure.ResourceManager.ContainerService.csproj @@ -1,6 +1,6 @@ - 1.3.0-beta.1 + 1.2.2 1.2.1 Azure.ResourceManager.ContainerService diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Custom/ContainerServiceAgentPoolResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Custom/ContainerServiceAgentPoolResource.cs index 4ed63cf3f19d..7fb0716e1298 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Custom/ContainerServiceAgentPoolResource.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Custom/ContainerServiceAgentPoolResource.cs @@ -13,78 +13,6 @@ namespace Azure.ResourceManager.ContainerService { public partial class ContainerServiceAgentPoolResource : ArmResource { - /// - /// Deletes an agent pool in the specified managed cluster. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}/agentPools/{agentPoolName} - /// - /// - /// Operation Id - /// AgentPools_Delete - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The cancellation token to use. - [Obsolete("This method is obsolete and will be removed in a future release", false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) - { - using var scope = _containerServiceAgentPoolAgentPoolsClientDiagnostics.CreateScope("ContainerServiceAgentPoolResource.Delete"); - scope.Start(); - try - { - var response = await _containerServiceAgentPoolAgentPoolsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new ContainerServiceArmOperation(_containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Deletes an agent pool in the specified managed cluster. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}/agentPools/{agentPoolName} - /// - /// - /// Operation Id - /// AgentPools_Delete - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The cancellation token to use. - [Obsolete("This method is obsolete and will be removed in a future release", false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) - { - using var scope = _containerServiceAgentPoolAgentPoolsClientDiagnostics.CreateScope("ContainerServiceAgentPoolResource.Delete"); - scope.Start(); - try - { - var response = _containerServiceAgentPoolAgentPoolsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new ContainerServiceArmOperation(_containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - /// /// Deletes an agent pool in the specified managed cluster. /// @@ -101,8 +29,6 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// ignore-pod-disruption-budget=true to delete those pods on a node without considering Pod Disruption Budget. /// The cancellation token to use. - [Obsolete("This method is obsolete and will be removed in a future release", false)] - [EditorBrowsable(EditorBrowsableState.Never)] public virtual async Task DeleteAsync(WaitUntil waitUntil, bool? ignorePodDisruptionBudget, CancellationToken cancellationToken) => await DeleteAsync(waitUntil, cancellationToken).ConfigureAwait(false); /// @@ -121,8 +47,6 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// ignore-pod-disruption-budget=true to delete those pods on a node without considering Pod Disruption Budget. /// The cancellation token to use. - [Obsolete("This method is obsolete and will be removed in a future release", false)] - [EditorBrowsable(EditorBrowsableState.Never)] public virtual ArmOperation Delete(WaitUntil waitUntil, bool? ignorePodDisruptionBudget, CancellationToken cancellationToken) => Delete(waitUntil, cancellationToken); } } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceAgentPoolCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceAgentPoolCollection.cs index 2303c347caf1..88b66a8d18dd 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceAgentPoolCollection.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceAgentPoolCollection.cs @@ -88,7 +88,7 @@ public virtual async Task> Creat try { var response = await _containerServiceAgentPoolAgentPoolsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, agentPoolName, data, cancellationToken).ConfigureAwait(false); - var operation = new ContainerServiceArmOperation(new ContainerServiceAgentPoolOperationSource(Client), _containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, agentPoolName, data).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(new ContainerServiceAgentPoolOperationSource(Client), _containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, agentPoolName, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -137,7 +137,7 @@ public virtual ArmOperation CreateOrUpdate(Wa try { var response = _containerServiceAgentPoolAgentPoolsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, agentPoolName, data, cancellationToken); - var operation = new ContainerServiceArmOperation(new ContainerServiceAgentPoolOperationSource(Client), _containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, agentPoolName, data).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(new ContainerServiceAgentPoolOperationSource(Client), _containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, agentPoolName, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletion(cancellationToken); return operation; diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceAgentPoolResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceAgentPoolResource.cs index 5bd85e86a58a..e3ed5337ca43 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceAgentPoolResource.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceAgentPoolResource.cs @@ -176,6 +176,90 @@ public virtual Response Get(CancellationToken } } + /// + /// Deletes an agent pool in the specified managed cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}/agentPools/{agentPoolName} + /// + /// + /// Operation Id + /// AgentPools_Delete + /// + /// + /// Default Api Version + /// 2023-10-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _containerServiceAgentPoolAgentPoolsClientDiagnostics.CreateScope("ContainerServiceAgentPoolResource.Delete"); + scope.Start(); + try + { + var response = await _containerServiceAgentPoolAgentPoolsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new ContainerServiceArmOperation(_containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an agent pool in the specified managed cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}/agentPools/{agentPoolName} + /// + /// + /// Operation Id + /// AgentPools_Delete + /// + /// + /// Default Api Version + /// 2023-10-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _containerServiceAgentPoolAgentPoolsClientDiagnostics.CreateScope("ContainerServiceAgentPoolResource.Delete"); + scope.Start(); + try + { + var response = _containerServiceAgentPoolAgentPoolsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new ContainerServiceArmOperation(_containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + /// /// Creates or updates an agent pool in the specified managed cluster. /// @@ -210,7 +294,7 @@ public virtual async Task> Updat try { var response = await _containerServiceAgentPoolAgentPoolsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); - var operation = new ContainerServiceArmOperation(new ContainerServiceAgentPoolOperationSource(Client), _containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(new ContainerServiceAgentPoolOperationSource(Client), _containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -256,7 +340,7 @@ public virtual ArmOperation Update(WaitUntil try { var response = _containerServiceAgentPoolAgentPoolsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); - var operation = new ContainerServiceArmOperation(new ContainerServiceAgentPoolOperationSource(Client), _containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(new ContainerServiceAgentPoolOperationSource(Client), _containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletion(cancellationToken); return operation; @@ -382,7 +466,7 @@ public virtual async Task UpgradeNodeImageVersionAsync(WaitUntil w try { var response = await _containerServiceAgentPoolAgentPoolsRestClient.UpgradeNodeImageVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new ContainerServiceArmOperation(_containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateUpgradeNodeImageVersionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(_containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateUpgradeNodeImageVersionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -424,7 +508,7 @@ public virtual ArmOperation UpgradeNodeImageVersion(WaitUntil waitUntil, Cancell try { var response = _containerServiceAgentPoolAgentPoolsRestClient.UpgradeNodeImageVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new ContainerServiceArmOperation(_containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateUpgradeNodeImageVersionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(_containerServiceAgentPoolAgentPoolsClientDiagnostics, Pipeline, _containerServiceAgentPoolAgentPoolsRestClient.CreateUpgradeNodeImageVersionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletionResponse(cancellationToken); return operation; diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceManagedClusterCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceManagedClusterCollection.cs index 878e24ac046b..a05f8d6c2d6d 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceManagedClusterCollection.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceManagedClusterCollection.cs @@ -89,7 +89,7 @@ public virtual async Task> try { var response = await _containerServiceManagedClusterManagedClustersRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, resourceName, data, cancellationToken).ConfigureAwait(false); - var operation = new ContainerServiceArmOperation(new ContainerServiceManagedClusterOperationSource(Client), _containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, data).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(new ContainerServiceManagedClusterOperationSource(Client), _containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -138,7 +138,7 @@ public virtual ArmOperation CreateOrUpda try { var response = _containerServiceManagedClusterManagedClustersRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, resourceName, data, cancellationToken); - var operation = new ContainerServiceArmOperation(new ContainerServiceManagedClusterOperationSource(Client), _containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, data).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(new ContainerServiceManagedClusterOperationSource(Client), _containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletion(cancellationToken); return operation; diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceManagedClusterResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceManagedClusterResource.cs index 2b9141432f5b..e9761b7a74dd 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceManagedClusterResource.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServiceManagedClusterResource.cs @@ -569,7 +569,7 @@ public virtual async Task> try { var response = await _containerServiceManagedClusterManagedClustersRestClient.UpdateTagsAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, containerServiceTagsObject, cancellationToken).ConfigureAwait(false); - var operation = new ContainerServiceArmOperation(new ContainerServiceManagedClusterOperationSource(Client), _containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateUpdateTagsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, containerServiceTagsObject).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(new ContainerServiceManagedClusterOperationSource(Client), _containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateUpdateTagsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, containerServiceTagsObject).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -615,7 +615,7 @@ public virtual ArmOperation Update(WaitU try { var response = _containerServiceManagedClusterManagedClustersRestClient.UpdateTags(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, containerServiceTagsObject, cancellationToken); - var operation = new ContainerServiceArmOperation(new ContainerServiceManagedClusterOperationSource(Client), _containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateUpdateTagsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, containerServiceTagsObject).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(new ContainerServiceManagedClusterOperationSource(Client), _containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateUpdateTagsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, containerServiceTagsObject).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletion(cancellationToken); return operation; @@ -975,7 +975,7 @@ public virtual async Task ResetServicePrincipalProfileAsync(WaitUn try { var response = await _containerServiceManagedClusterManagedClustersRestClient.ResetServicePrincipalProfileAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedClusterServicePrincipalProfile, cancellationToken).ConfigureAwait(false); - var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateResetServicePrincipalProfileRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedClusterServicePrincipalProfile).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateResetServicePrincipalProfileRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedClusterServicePrincipalProfile).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -1021,7 +1021,7 @@ public virtual ArmOperation ResetServicePrincipalProfile(WaitUntil waitUntil, Ma try { var response = _containerServiceManagedClusterManagedClustersRestClient.ResetServicePrincipalProfile(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedClusterServicePrincipalProfile, cancellationToken); - var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateResetServicePrincipalProfileRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedClusterServicePrincipalProfile).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateResetServicePrincipalProfileRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedClusterServicePrincipalProfile).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletionResponse(cancellationToken); return operation; @@ -1155,7 +1155,7 @@ public virtual async Task RotateClusterCertificatesAsync(WaitUntil try { var response = await _containerServiceManagedClusterManagedClustersRestClient.RotateClusterCertificatesAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateRotateClusterCertificatesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateRotateClusterCertificatesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -1197,7 +1197,7 @@ public virtual ArmOperation RotateClusterCertificates(WaitUntil waitUntil, Cance try { var response = _containerServiceManagedClusterManagedClustersRestClient.RotateClusterCertificates(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateRotateClusterCertificatesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateRotateClusterCertificatesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletionResponse(cancellationToken); return operation; @@ -1407,7 +1407,7 @@ public virtual async Task StopAsync(WaitUntil waitUntil, Cancellat try { var response = await _containerServiceManagedClusterManagedClustersRestClient.StopAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateStopRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateStopRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -1449,7 +1449,7 @@ public virtual ArmOperation Stop(WaitUntil waitUntil, CancellationToken cancella try { var response = _containerServiceManagedClusterManagedClustersRestClient.Stop(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateStopRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateStopRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletionResponse(cancellationToken); return operation; @@ -1491,7 +1491,7 @@ public virtual async Task StartAsync(WaitUntil waitUntil, Cancella try { var response = await _containerServiceManagedClusterManagedClustersRestClient.StartAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateStartRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateStartRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -1533,7 +1533,7 @@ public virtual ArmOperation Start(WaitUntil waitUntil, CancellationToken cancell try { var response = _containerServiceManagedClusterManagedClustersRestClient.Start(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateStartRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(_containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateStartRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletionResponse(cancellationToken); return operation; @@ -1579,7 +1579,7 @@ public virtual async Task> RunComma try { var response = await _containerServiceManagedClusterManagedClustersRestClient.RunCommandAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken).ConfigureAwait(false); - var operation = new ContainerServiceArmOperation(new ManagedClusterRunCommandResultOperationSource(), _containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateRunCommandRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(new ManagedClusterRunCommandResultOperationSource(), _containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateRunCommandRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -1625,7 +1625,7 @@ public virtual ArmOperation RunCommand(WaitUntil try { var response = _containerServiceManagedClusterManagedClustersRestClient.RunCommand(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken); - var operation = new ContainerServiceArmOperation(new ManagedClusterRunCommandResultOperationSource(), _containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateRunCommandRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(new ManagedClusterRunCommandResultOperationSource(), _containerServiceManagedClusterManagedClustersClientDiagnostics, Pipeline, _containerServiceManagedClusterManagedClustersRestClient.CreateRunCommandRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletion(cancellationToken); return operation; diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServicePrivateEndpointConnectionResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServicePrivateEndpointConnectionResource.cs index 58ad6fe51598..56db01f3bb7c 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServicePrivateEndpointConnectionResource.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/ContainerServicePrivateEndpointConnectionResource.cs @@ -198,7 +198,7 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell try { var response = await _containerServicePrivateEndpointConnectionPrivateEndpointConnectionsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new ContainerServiceArmOperation(_containerServicePrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _containerServicePrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(_containerServicePrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _containerServicePrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -240,7 +240,7 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel try { var response = _containerServicePrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new ContainerServiceArmOperation(_containerServicePrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _containerServicePrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location, apiVersionOverrideValue: "2017-08-31"); + var operation = new ContainerServiceArmOperation(_containerServicePrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _containerServicePrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletionResponse(cancellationToken); return operation; diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/autorest.md b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/autorest.md index 6f8fde38aa21..26f40157fee1 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/src/autorest.md +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/src/autorest.md @@ -12,6 +12,9 @@ require: https://github.com/Azure/azure-rest-api-specs/blob/8e674dd2a88ae73868c6 #tag: package-2023-10 output-folder: $(this-folder)/Generated clear-output-folder: true +sample-gen: + output-folder: $(this-folder)/../samples/Generated + clear-output-folder: true skip-csproj: true modelerfour: flatten-payloads: false @@ -190,21 +193,6 @@ prepend-rp-prefix: - TrustedAccessRoleRule - TrustedAccessRoleBindingProvisioningState -operations-to-lro-api-version-override: - AgentPools_CreateOrUpdate: "2017-08-31" - AgentPools_Delete: "2017-08-31" - AgentPools_UpgradeNodeImageVersion: "2017-08-31" - ManagedClusters_CreateOrUpdate: "2017-08-31" - ManagedClusters_Delete: "2017-08-31" - ManagedClusters_UpdateTags: "2017-08-31" - ManagedClusters_ResetServicePrincipalProfile: "2017-08-31" - ManagedClusters_ResetAADProfile: "2017-08-31" - ManagedClusters_RotateClusterCertificates: "2017-08-31" - ManagedClusters_Stop: "2017-08-31" - ManagedClusters_Start: "2017-08-31" - ManagedClusters_RunCommand: "2017-08-31" - PrivateEndpointConnections_Delete: "2017-08-31" - directive: - from: managedClusters.json where: $.definitions.AgentPoolAvailableVersionsProperties.properties.agentPoolVersions.items diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/tests/ContainerServiceAgentPoolTests.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/tests/ContainerServiceAgentPoolTests.cs new file mode 100644 index 000000000000..a5043526e096 --- /dev/null +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/tests/ContainerServiceAgentPoolTests.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.ContainerService.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ContainerService.Tests +{ + public class ContainerServiceAgentPoolTests : ContainerServiceManagementTestBase + { + public ContainerServiceAgentPoolTests(bool isAsync) + : base(isAsync) + { + } + + [RecordedTest] + public async Task CreateListGetDelete() + { + ResourceGroupResource rg = await CreateResourceGroupAsync(Subscription, "testaksrg", AzureLocation.EastUS); + var clusterCollection = rg.GetContainerServiceManagedClusters(); + string clusterName = Recording.GenerateAssetName("akscluster"); + // Create cluster + ContainerServiceManagedClusterResource cluster = await CreateContainerServiceAsync(rg, clusterName, rg.Data.Location); + Assert.AreEqual(clusterName, cluster.Data.Name); + Assert.AreEqual(DnsPrefix, cluster.Data.DnsPrefix); + // Create agent pool + ContainerServiceAgentPoolCollection collection = cluster.GetContainerServiceAgentPools(); + string agentPoolName = Recording.GenerateAssetName("ap"); + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + { + Count = 3, + VmSize = "Standard_DS2_v2", + OSType = ContainerServiceOSType.Linux, + OrchestratorVersion = "", + EnableEncryptionAtHost = true + }; + var lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data).ConfigureAwait(false); + ContainerServiceAgentPoolResource agentPool = lro.Value; + Assert.AreEqual(agentPoolName, agentPool.Data.Name); + // List Agent Pool + int count = 0; + await foreach (var pool in collection.GetAllAsync()) + { + if (pool.Data.Name == agentPoolName) + { + Assert.AreEqual(pool.Data.Name, agentPoolName); + count++; + break; + } + } + Assert.AreEqual(count, 1); + // Get Agent Pool + ContainerServiceAgentPoolResource agentPoolGet = await agentPool.GetAsync(); + Assert.AreEqual(agentPoolGet.Data.Name, agentPoolName); + // Delete Agent Pool + await agentPoolGet.DeleteAsync(WaitUntil.Completed); + // Delete Cluster + await cluster.DeleteAsync(WaitUntil.Completed); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/tests/ContainerServiceCollectionTests.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/tests/ContainerServiceCollectionTests.cs index b6750d5998a1..88968e199404 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/tests/ContainerServiceCollectionTests.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/tests/ContainerServiceCollectionTests.cs @@ -10,7 +10,6 @@ namespace Azure.ResourceManager.ContainerService.Tests { - [LiveOnly(Reason = "Tests rely on ClientId which cannot be stored in recordings.")] public class ContainerServiceCollectionTests : ContainerServiceManagementTestBase { public ContainerServiceCollectionTests(bool isAsync) @@ -18,7 +17,6 @@ public ContainerServiceCollectionTests(bool isAsync) { } - [TestCase] [RecordedTest] public async Task CreateListGetDelete() { @@ -42,7 +40,6 @@ public async Task CreateListGetDelete() await clusterFromGet.DeleteAsync(WaitUntil.Completed); } - [TestCase] [RecordedTest] public async Task Update() { @@ -62,7 +59,6 @@ public async Task Update() await clusterFromUpdate.DeleteAsync(WaitUntil.Completed); } - [TestCase] [RecordedTest] public async Task GetCredentials() {