diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_DataPolicyManifestCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_DataPolicyManifestCollection.cs deleted file mode 100644 index 48e49d0c1148..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_DataPolicyManifestCollection.cs +++ /dev/null @@ -1,181 +0,0 @@ -// 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.Resources.Samples -{ - public partial class Sample_DataPolicyManifestCollection - { - // Retrieve a data policy manifest by policy mode - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveADataPolicyManifestByPolicyMode() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json - // this example is just showing the usage of "DataPolicyManifests_GetByPolicyMode" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this DataPolicyManifestResource - DataPolicyManifestCollection collection = tenant.GetDataPolicyManifests(); - - // invoke the operation - string policyMode = "Microsoft.KeyVault.Data"; - DataPolicyManifestResource result = await collection.GetAsync(policyMode); - - // 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 - DataPolicyManifestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a data policy manifest by policy mode - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_RetrieveADataPolicyManifestByPolicyMode() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json - // this example is just showing the usage of "DataPolicyManifests_GetByPolicyMode" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this DataPolicyManifestResource - DataPolicyManifestCollection collection = tenant.GetDataPolicyManifests(); - - // invoke the operation - string policyMode = "Microsoft.KeyVault.Data"; - bool result = await collection.ExistsAsync(policyMode); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Retrieve a data policy manifest by policy mode - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_RetrieveADataPolicyManifestByPolicyMode() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json - // this example is just showing the usage of "DataPolicyManifests_GetByPolicyMode" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this DataPolicyManifestResource - DataPolicyManifestCollection collection = tenant.GetDataPolicyManifests(); - - // invoke the operation - string policyMode = "Microsoft.KeyVault.Data"; - NullableResponse response = await collection.GetIfExistsAsync(policyMode); - DataPolicyManifestResource 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 - DataPolicyManifestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List data policy manifests - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListDataPolicyManifests() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json - // this example is just showing the usage of "DataPolicyManifests_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this DataPolicyManifestResource - DataPolicyManifestCollection collection = tenant.GetDataPolicyManifests(); - - // invoke the operation and iterate over the result - await foreach (DataPolicyManifestResource 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 - DataPolicyManifestData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - - // List data policy manifests with namespace filter - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListDataPolicyManifestsWithNamespaceFilter() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifestsNamespaceFilter.json - // this example is just showing the usage of "DataPolicyManifests_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this DataPolicyManifestResource - DataPolicyManifestCollection collection = tenant.GetDataPolicyManifests(); - - // invoke the operation and iterate over the result - string filter = "namespace eq 'Microsoft.KeyVault'"; - await foreach (DataPolicyManifestResource item in collection.GetAllAsync(filter: filter)) - { - // 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 - DataPolicyManifestData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_DataPolicyManifestResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_DataPolicyManifestResource.cs deleted file mode 100644 index a65456a44f8d..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_DataPolicyManifestResource.cs +++ /dev/null @@ -1,46 +0,0 @@ -// 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.Resources.Samples -{ - public partial class Sample_DataPolicyManifestResource - { - // Retrieve a data policy manifest by policy mode - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveADataPolicyManifestByPolicyMode() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json - // this example is just showing the usage of "DataPolicyManifests_GetByPolicyMode" 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 DataPolicyManifestResource created on azure - // for more information of creating DataPolicyManifestResource, please refer to the document of DataPolicyManifestResource - string policyMode = "Microsoft.KeyVault.Data"; - ResourceIdentifier dataPolicyManifestResourceId = DataPolicyManifestResource.CreateResourceIdentifier(policyMode); - DataPolicyManifestResource dataPolicyManifest = client.GetDataPolicyManifestResource(dataPolicyManifestResourceId); - - // invoke the operation - DataPolicyManifestResource result = await dataPolicyManifest.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 - DataPolicyManifestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_FeatureCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_FeatureCollection.cs deleted file mode 100644 index 68627f8b8440..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_FeatureCollection.cs +++ /dev/null @@ -1,159 +0,0 @@ -// 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.Resources.Samples -{ - public partial class Sample_FeatureCollection - { - // List provider Features - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListProviderFeatures() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listProviderFeatures.json - // this example is just showing the usage of "Features_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 ResourceProviderResource created on azure - // for more information of creating ResourceProviderResource, please refer to the document of ResourceProviderResource - string subscriptionId = "subid"; - string resourceProviderNamespace = "Resource Provider Namespace"; - ResourceIdentifier resourceProviderResourceId = ResourceProviderResource.CreateResourceIdentifier(subscriptionId, resourceProviderNamespace); - ResourceProviderResource resourceProvider = client.GetResourceProviderResource(resourceProviderResourceId); - - // get the collection of this FeatureResource - FeatureCollection collection = resourceProvider.GetFeatures(); - - // invoke the operation and iterate over the result - await foreach (FeatureResource 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 - FeatureData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - - // Get feature - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetFeature() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json - // this example is just showing the usage of "Features_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 ResourceProviderResource created on azure - // for more information of creating ResourceProviderResource, please refer to the document of ResourceProviderResource - string subscriptionId = "subid"; - string resourceProviderNamespace = "Resource Provider Namespace"; - ResourceIdentifier resourceProviderResourceId = ResourceProviderResource.CreateResourceIdentifier(subscriptionId, resourceProviderNamespace); - ResourceProviderResource resourceProvider = client.GetResourceProviderResource(resourceProviderResourceId); - - // get the collection of this FeatureResource - FeatureCollection collection = resourceProvider.GetFeatures(); - - // invoke the operation - string featureName = "feature"; - FeatureResource result = await collection.GetAsync(featureName); - - // 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 - FeatureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get feature - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetFeature() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json - // this example is just showing the usage of "Features_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 ResourceProviderResource created on azure - // for more information of creating ResourceProviderResource, please refer to the document of ResourceProviderResource - string subscriptionId = "subid"; - string resourceProviderNamespace = "Resource Provider Namespace"; - ResourceIdentifier resourceProviderResourceId = ResourceProviderResource.CreateResourceIdentifier(subscriptionId, resourceProviderNamespace); - ResourceProviderResource resourceProvider = client.GetResourceProviderResource(resourceProviderResourceId); - - // get the collection of this FeatureResource - FeatureCollection collection = resourceProvider.GetFeatures(); - - // invoke the operation - string featureName = "feature"; - bool result = await collection.ExistsAsync(featureName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Get feature - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetFeature() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json - // this example is just showing the usage of "Features_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 ResourceProviderResource created on azure - // for more information of creating ResourceProviderResource, please refer to the document of ResourceProviderResource - string subscriptionId = "subid"; - string resourceProviderNamespace = "Resource Provider Namespace"; - ResourceIdentifier resourceProviderResourceId = ResourceProviderResource.CreateResourceIdentifier(subscriptionId, resourceProviderNamespace); - ResourceProviderResource resourceProvider = client.GetResourceProviderResource(resourceProviderResourceId); - - // get the collection of this FeatureResource - FeatureCollection collection = resourceProvider.GetFeatures(); - - // invoke the operation - string featureName = "feature"; - NullableResponse response = await collection.GetIfExistsAsync(featureName); - FeatureResource 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 - FeatureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_FeatureResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_FeatureResource.cs deleted file mode 100644 index ecca03a05f8f..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_FeatureResource.cs +++ /dev/null @@ -1,110 +0,0 @@ -// 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.Resources.Samples -{ - public partial class Sample_FeatureResource - { - // Get feature - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetFeature() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json - // this example is just showing the usage of "Features_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 FeatureResource created on azure - // for more information of creating FeatureResource, please refer to the document of FeatureResource - string subscriptionId = "subid"; - string resourceProviderNamespace = "Resource Provider Namespace"; - string featureName = "feature"; - ResourceIdentifier featureResourceId = FeatureResource.CreateResourceIdentifier(subscriptionId, resourceProviderNamespace, featureName); - FeatureResource feature = client.GetFeatureResource(featureResourceId); - - // invoke the operation - FeatureResource result = await feature.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 - FeatureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Register feature - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Register_RegisterFeature() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/registerFeature.json - // this example is just showing the usage of "Features_Register" 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 FeatureResource created on azure - // for more information of creating FeatureResource, please refer to the document of FeatureResource - string subscriptionId = "subid"; - string resourceProviderNamespace = "Resource Provider Namespace"; - string featureName = "feature"; - ResourceIdentifier featureResourceId = FeatureResource.CreateResourceIdentifier(subscriptionId, resourceProviderNamespace, featureName); - FeatureResource feature = client.GetFeatureResource(featureResourceId); - - // invoke the operation - FeatureResource result = await feature.RegisterAsync(); - - // 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 - FeatureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Register feature - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Unregister_RegisterFeature() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/unregisterFeature.json - // this example is just showing the usage of "Features_Unregister" 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 FeatureResource created on azure - // for more information of creating FeatureResource, please refer to the document of FeatureResource - string subscriptionId = "ff23096b-f5a2-46ea-bd62-59c3e93fef9a"; - string resourceProviderNamespace = "Resource Provider Namespace"; - string featureName = "feature"; - ResourceIdentifier featureResourceId = FeatureResource.CreateResourceIdentifier(subscriptionId, resourceProviderNamespace, featureName); - FeatureResource feature = client.GetFeatureResource(featureResourceId); - - // invoke the operation - FeatureResource result = await feature.UnregisterAsync(); - - // 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 - FeatureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupCollection.cs deleted file mode 100644 index 9ebcafbd812d..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupCollection.cs +++ /dev/null @@ -1,673 +0,0 @@ -// 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.ManagementGroups.Models; -using Azure.ResourceManager.Resources; - -namespace Azure.ResourceManager.ManagementGroups.Samples -{ - public partial class Sample_ManagementGroupCollection - { - // ListManagementGroups - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListManagementGroups() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/ListManagementGroups.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation and iterate over the result - string cacheControl = "no-cache"; - await foreach (ManagementGroupResource item in collection.GetAllAsync(cacheControl: cacheControl)) - { - // 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 - ManagementGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - - // GetManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroup.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - string cacheControl = "no-cache"; - ManagementGroupResource result = await collection.GetAsync(groupId, cacheControl: cacheControl); - - // 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // GetManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroup.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - string cacheControl = "no-cache"; - bool result = await collection.ExistsAsync(groupId, cacheControl: cacheControl); - - Console.WriteLine($"Succeeded: {result}"); - } - - // GetManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroup.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - string cacheControl = "no-cache"; - NullableResponse response = await collection.GetIfExistsAsync(groupId, cacheControl: cacheControl); - ManagementGroupResource 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // GetManagementGroupWithAncestors - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetManagementGroupWithAncestors() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-00000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Ancestors; - string cacheControl = "no-cache"; - ManagementGroupResource result = await collection.GetAsync(groupId, expand: expand, cacheControl: cacheControl); - - // 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // GetManagementGroupWithAncestors - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetManagementGroupWithAncestors() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-00000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Ancestors; - string cacheControl = "no-cache"; - bool result = await collection.ExistsAsync(groupId, expand: expand, cacheControl: cacheControl); - - Console.WriteLine($"Succeeded: {result}"); - } - - // GetManagementGroupWithAncestors - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetManagementGroupWithAncestors() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-00000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Ancestors; - string cacheControl = "no-cache"; - NullableResponse response = await collection.GetIfExistsAsync(groupId, expand: expand, cacheControl: cacheControl); - ManagementGroupResource 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // GetManagementGroupWithExpand - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetManagementGroupWithExpand() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpand.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; - string cacheControl = "no-cache"; - ManagementGroupResource result = await collection.GetAsync(groupId, expand: expand, cacheControl: cacheControl); - - // 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // GetManagementGroupWithExpand - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetManagementGroupWithExpand() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpand.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; - string cacheControl = "no-cache"; - bool result = await collection.ExistsAsync(groupId, expand: expand, cacheControl: cacheControl); - - Console.WriteLine($"Succeeded: {result}"); - } - - // GetManagementGroupWithExpand - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetManagementGroupWithExpand() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpand.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; - string cacheControl = "no-cache"; - NullableResponse response = await collection.GetIfExistsAsync(groupId, expand: expand, cacheControl: cacheControl); - ManagementGroupResource 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // GetManagementGroupWithPath - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetManagementGroupWithPath() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithPath.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Path; - string cacheControl = "no-cache"; - ManagementGroupResource result = await collection.GetAsync(groupId, expand: expand, cacheControl: cacheControl); - - // 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // GetManagementGroupWithPath - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetManagementGroupWithPath() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithPath.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Path; - string cacheControl = "no-cache"; - bool result = await collection.ExistsAsync(groupId, expand: expand, cacheControl: cacheControl); - - Console.WriteLine($"Succeeded: {result}"); - } - - // GetManagementGroupWithPath - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetManagementGroupWithPath() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithPath.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Path; - string cacheControl = "no-cache"; - NullableResponse response = await collection.GetIfExistsAsync(groupId, expand: expand, cacheControl: cacheControl); - ManagementGroupResource 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // GetManagementGroupsWithExpandAndRecurse - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetManagementGroupsWithExpandAndRecurse() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpandAndRecurse.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; - bool? recurse = true; - string cacheControl = "no-cache"; - ManagementGroupResource result = await collection.GetAsync(groupId, expand: expand, recurse: recurse, cacheControl: cacheControl); - - // 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // GetManagementGroupsWithExpandAndRecurse - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetManagementGroupsWithExpandAndRecurse() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpandAndRecurse.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; - bool? recurse = true; - string cacheControl = "no-cache"; - bool result = await collection.ExistsAsync(groupId, expand: expand, recurse: recurse, cacheControl: cacheControl); - - Console.WriteLine($"Succeeded: {result}"); - } - - // GetManagementGroupsWithExpandAndRecurse - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetManagementGroupsWithExpandAndRecurse() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpandAndRecurse.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; - bool? recurse = true; - string cacheControl = "no-cache"; - NullableResponse response = await collection.GetIfExistsAsync(groupId, expand: expand, recurse: recurse, cacheControl: cacheControl); - ManagementGroupResource 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // PutManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_PutManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/PutManagementGroup.json - // this example is just showing the usage of "ManagementGroups_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - string groupId = "ChildGroup"; - ManagementGroupCreateOrUpdateContent content = new ManagementGroupCreateOrUpdateContent() - { - DisplayName = "ChildGroup", - Details = new CreateManagementGroupDetails() - { - Parent = new ManagementGroupParentCreateOptions() - { - Id = "/providers/Microsoft.Management/managementGroups/RootGroup", - }, - }, - }; - string cacheControl = "no-cache"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupId, content, cacheControl: cacheControl); - ManagementGroupResource 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // CheckManagementGroupNameAvailability - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CheckNameAvailability_CheckManagementGroupNameAvailability() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/CheckManagementGroupNameAvailability.json - // this example is just showing the usage of "ManagementGroups_CheckNameAvailability" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation - ManagementGroupNameAvailabilityContent content = new ManagementGroupNameAvailabilityContent() - { - Name = "nameTocheck", - ResourceType = new ResourceType("Microsoft.Management/managementGroups"), - }; - ManagementGroupNameAvailabilityResult result = await collection.CheckNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - // GetEntities - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetEntities_GetEntities() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetEntities.json - // this example is just showing the usage of "Entities_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ManagementGroupResource - ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - - // invoke the operation and iterate over the result - ManagementGroupCollectionGetEntitiesOptions options = new ManagementGroupCollectionGetEntitiesOptions() { }; - await foreach (EntityData item in collection.GetEntitiesAsync(options)) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionCollection.cs deleted file mode 100644 index 2d265be743ae..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionCollection.cs +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.ManagementGroups; -using Azure.ResourceManager.Resources.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_ManagementGroupPolicyDefinitionCollection - { - // Create or update a policy definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicyDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicyDefinitions_CreateOrUpdateAtManagementGroup" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "MyManagementGroup"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupPolicyDefinitionResource - ManagementGroupPolicyDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicyDefinitions(); - - // invoke the operation - string policyDefinitionName = "ResourceNaming"; - PolicyDefinitionData data = new PolicyDefinitionData() - { - Mode = "All", - DisplayName = "Enforce resource naming convention", - Description = "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - PolicyRule = BinaryData.FromObjectAsJson(new Dictionary() - { - ["if"] = new Dictionary() - { - ["not"] = new Dictionary() - { - ["field"] = "name", - ["like"] = "[concat(parameters('prefix'), '*', parameters('suffix'))]" - } - }, - ["then"] = new Dictionary() - { - ["effect"] = "deny" - } - }), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Naming" - }), - Parameters = -{ -["prefix"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Prefix", -Description = "Resource name prefix", -}, -}, -["suffix"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Suffix", -Description = "Resource name suffix", -}, -}, -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyDefinitionName, data); - ManagementGroupPolicyDefinitionResource 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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicyDefinitions_GetAtManagementGroup" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "MyManagementGroup"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupPolicyDefinitionResource - ManagementGroupPolicyDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicyDefinitions(); - - // invoke the operation - string policyDefinitionName = "ResourceNaming"; - ManagementGroupPolicyDefinitionResource result = await collection.GetAsync(policyDefinitionName); - - // 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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_RetrieveAPolicyDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicyDefinitions_GetAtManagementGroup" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "MyManagementGroup"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupPolicyDefinitionResource - ManagementGroupPolicyDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicyDefinitions(); - - // invoke the operation - string policyDefinitionName = "ResourceNaming"; - bool result = await collection.ExistsAsync(policyDefinitionName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Retrieve a policy definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_RetrieveAPolicyDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicyDefinitions_GetAtManagementGroup" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "MyManagementGroup"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupPolicyDefinitionResource - ManagementGroupPolicyDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicyDefinitions(); - - // invoke the operation - string policyDefinitionName = "ResourceNaming"; - NullableResponse response = await collection.GetIfExistsAsync(policyDefinitionName); - ManagementGroupPolicyDefinitionResource 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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List policy definitions by management group - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListPolicyDefinitionsByManagementGroup() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitionsByManagementGroup.json - // this example is just showing the usage of "PolicyDefinitions_ListByManagementGroup" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "MyManagementGroup"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupPolicyDefinitionResource - ManagementGroupPolicyDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicyDefinitions(); - - // invoke the operation and iterate over the result - await foreach (ManagementGroupPolicyDefinitionResource 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 - PolicyDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionResource.cs deleted file mode 100644 index ca29d17b6d8b..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionResource.cs +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.Resources.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_ManagementGroupPolicyDefinitionResource - { - // Create or update a policy definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateOrUpdateAPolicyDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicyDefinitions_CreateOrUpdateAtManagementGroup" 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 ManagementGroupPolicyDefinitionResource created on azure - // for more information of creating ManagementGroupPolicyDefinitionResource, please refer to the document of ManagementGroupPolicyDefinitionResource - string managementGroupId = "MyManagementGroup"; - string policyDefinitionName = "ResourceNaming"; - ResourceIdentifier managementGroupPolicyDefinitionResourceId = ManagementGroupPolicyDefinitionResource.CreateResourceIdentifier(managementGroupId, policyDefinitionName); - ManagementGroupPolicyDefinitionResource managementGroupPolicyDefinition = client.GetManagementGroupPolicyDefinitionResource(managementGroupPolicyDefinitionResourceId); - - // invoke the operation - PolicyDefinitionData data = new PolicyDefinitionData() - { - Mode = "All", - DisplayName = "Enforce resource naming convention", - Description = "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - PolicyRule = BinaryData.FromObjectAsJson(new Dictionary() - { - ["if"] = new Dictionary() - { - ["not"] = new Dictionary() - { - ["field"] = "name", - ["like"] = "[concat(parameters('prefix'), '*', parameters('suffix'))]" - } - }, - ["then"] = new Dictionary() - { - ["effect"] = "deny" - } - }), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Naming" - }), - Parameters = -{ -["prefix"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Prefix", -Description = "Resource name prefix", -}, -}, -["suffix"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Suffix", -Description = "Resource name suffix", -}, -}, -}, - }; - ArmOperation lro = await managementGroupPolicyDefinition.UpdateAsync(WaitUntil.Completed, data); - ManagementGroupPolicyDefinitionResource 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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Delete a policy definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteAPolicyDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicyDefinitions_DeleteAtManagementGroup" 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 ManagementGroupPolicyDefinitionResource created on azure - // for more information of creating ManagementGroupPolicyDefinitionResource, please refer to the document of ManagementGroupPolicyDefinitionResource - string managementGroupId = "MyManagementGroup"; - string policyDefinitionName = "ResourceNaming"; - ResourceIdentifier managementGroupPolicyDefinitionResourceId = ManagementGroupPolicyDefinitionResource.CreateResourceIdentifier(managementGroupId, policyDefinitionName); - ManagementGroupPolicyDefinitionResource managementGroupPolicyDefinition = client.GetManagementGroupPolicyDefinitionResource(managementGroupPolicyDefinitionResourceId); - - // invoke the operation - await managementGroupPolicyDefinition.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // Retrieve a policy definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicyDefinitions_GetAtManagementGroup" 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 ManagementGroupPolicyDefinitionResource created on azure - // for more information of creating ManagementGroupPolicyDefinitionResource, please refer to the document of ManagementGroupPolicyDefinitionResource - string managementGroupId = "MyManagementGroup"; - string policyDefinitionName = "ResourceNaming"; - ResourceIdentifier managementGroupPolicyDefinitionResourceId = ManagementGroupPolicyDefinitionResource.CreateResourceIdentifier(managementGroupId, policyDefinitionName); - ManagementGroupPolicyDefinitionResource managementGroupPolicyDefinition = client.GetManagementGroupPolicyDefinitionResource(managementGroupPolicyDefinitionResourceId); - - // invoke the operation - ManagementGroupPolicyDefinitionResource result = await managementGroupPolicyDefinition.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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionCollection.cs deleted file mode 100644 index 4493d95866e5..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionCollection.cs +++ /dev/null @@ -1,320 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.ManagementGroups; -using Azure.ResourceManager.Resources.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_ManagementGroupPolicySetDefinitionCollection - { - // Create or update a policy set definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicySetDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_CreateOrUpdateAtManagementGroup" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "MyManagementGroup"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupPolicySetDefinitionResource - ManagementGroupPolicySetDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "CostManagement"; - PolicySetDefinitionData data = new PolicySetDefinitionData() - { - DisplayName = "Cost Management", - Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Cost Management" - }), - PolicyDefinitions = -{ -new PolicyDefinitionReference("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") -{ -Parameters = -{ -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, -}, -PolicyDefinitionReferenceId = "Limit_Skus", -},new PolicyDefinitionReference("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") -{ -Parameters = -{ -["prefix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"DeptA\""), -}, -["suffix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policySetDefinitionName, data); - ManagementGroupPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create or update a policy set definition with groups at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_CreateOrUpdateAtManagementGroup" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "MyManagementGroup"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupPolicySetDefinitionResource - ManagementGroupPolicySetDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "CostManagement"; - PolicySetDefinitionData data = new PolicySetDefinitionData() - { - DisplayName = "Cost Management", - Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Cost Management" - }), - PolicyDefinitions = -{ -new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") -{ -Parameters = -{ -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, -}, -PolicyDefinitionReferenceId = "Limit_Skus", -GroupNames = -{ -"CostSaving" -}, -},new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") -{ -Parameters = -{ -["prefix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"DeptA\""), -}, -["suffix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", -GroupNames = -{ -"Organizational" -}, -} -}, - PolicyDefinitionGroups = -{ -new PolicyDefinitionGroup("CostSaving") -{ -DisplayName = "Cost Management Policies", -Description = "Policies designed to control spend within a subscription.", -},new PolicyDefinitionGroup("Organizational") -{ -DisplayName = "Organizational Policies", -Description = "Policies that help enforce resource organization standards within a subscription.", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policySetDefinitionName, data); - ManagementGroupPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy set definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicySetDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_GetAtManagementGroup" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "MyManagementGroup"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupPolicySetDefinitionResource - ManagementGroupPolicySetDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "CostManagement"; - ManagementGroupPolicySetDefinitionResource result = await collection.GetAsync(policySetDefinitionName); - - // 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy set definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_RetrieveAPolicySetDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_GetAtManagementGroup" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "MyManagementGroup"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupPolicySetDefinitionResource - ManagementGroupPolicySetDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "CostManagement"; - bool result = await collection.ExistsAsync(policySetDefinitionName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Retrieve a policy set definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_RetrieveAPolicySetDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_GetAtManagementGroup" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "MyManagementGroup"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupPolicySetDefinitionResource - ManagementGroupPolicySetDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "CostManagement"; - NullableResponse response = await collection.GetIfExistsAsync(policySetDefinitionName); - ManagementGroupPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List policy set definitions at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListPolicySetDefinitionsAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitionsByManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_ListByManagementGroup" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "MyManagementGroup"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupPolicySetDefinitionResource - ManagementGroupPolicySetDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicySetDefinitions(); - - // invoke the operation and iterate over the result - await foreach (ManagementGroupPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionResource.cs deleted file mode 100644 index 9dab616445bb..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionResource.cs +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.Resources.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_ManagementGroupPolicySetDefinitionResource - { - // Create or update a policy set definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateOrUpdateAPolicySetDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_CreateOrUpdateAtManagementGroup" 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 ManagementGroupPolicySetDefinitionResource created on azure - // for more information of creating ManagementGroupPolicySetDefinitionResource, please refer to the document of ManagementGroupPolicySetDefinitionResource - string managementGroupId = "MyManagementGroup"; - string policySetDefinitionName = "CostManagement"; - ResourceIdentifier managementGroupPolicySetDefinitionResourceId = ManagementGroupPolicySetDefinitionResource.CreateResourceIdentifier(managementGroupId, policySetDefinitionName); - ManagementGroupPolicySetDefinitionResource managementGroupPolicySetDefinition = client.GetManagementGroupPolicySetDefinitionResource(managementGroupPolicySetDefinitionResourceId); - - // invoke the operation - PolicySetDefinitionData data = new PolicySetDefinitionData() - { - DisplayName = "Cost Management", - Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Cost Management" - }), - PolicyDefinitions = -{ -new PolicyDefinitionReference("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") -{ -Parameters = -{ -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, -}, -PolicyDefinitionReferenceId = "Limit_Skus", -},new PolicyDefinitionReference("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") -{ -Parameters = -{ -["prefix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"DeptA\""), -}, -["suffix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", -} -}, - }; - ArmOperation lro = await managementGroupPolicySetDefinition.UpdateAsync(WaitUntil.Completed, data); - ManagementGroupPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create or update a policy set definition with groups at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_CreateOrUpdateAtManagementGroup" 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 ManagementGroupPolicySetDefinitionResource created on azure - // for more information of creating ManagementGroupPolicySetDefinitionResource, please refer to the document of ManagementGroupPolicySetDefinitionResource - string managementGroupId = "MyManagementGroup"; - string policySetDefinitionName = "CostManagement"; - ResourceIdentifier managementGroupPolicySetDefinitionResourceId = ManagementGroupPolicySetDefinitionResource.CreateResourceIdentifier(managementGroupId, policySetDefinitionName); - ManagementGroupPolicySetDefinitionResource managementGroupPolicySetDefinition = client.GetManagementGroupPolicySetDefinitionResource(managementGroupPolicySetDefinitionResourceId); - - // invoke the operation - PolicySetDefinitionData data = new PolicySetDefinitionData() - { - DisplayName = "Cost Management", - Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Cost Management" - }), - PolicyDefinitions = -{ -new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") -{ -Parameters = -{ -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, -}, -PolicyDefinitionReferenceId = "Limit_Skus", -GroupNames = -{ -"CostSaving" -}, -},new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") -{ -Parameters = -{ -["prefix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"DeptA\""), -}, -["suffix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", -GroupNames = -{ -"Organizational" -}, -} -}, - PolicyDefinitionGroups = -{ -new PolicyDefinitionGroup("CostSaving") -{ -DisplayName = "Cost Management Policies", -Description = "Policies designed to control spend within a subscription.", -},new PolicyDefinitionGroup("Organizational") -{ -DisplayName = "Organizational Policies", -Description = "Policies that help enforce resource organization standards within a subscription.", -} -}, - }; - ArmOperation lro = await managementGroupPolicySetDefinition.UpdateAsync(WaitUntil.Completed, data); - ManagementGroupPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Delete a policy set definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteAPolicySetDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_DeleteAtManagementGroup" 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 ManagementGroupPolicySetDefinitionResource created on azure - // for more information of creating ManagementGroupPolicySetDefinitionResource, please refer to the document of ManagementGroupPolicySetDefinitionResource - string managementGroupId = "MyManagementGroup"; - string policySetDefinitionName = "CostManagement"; - ResourceIdentifier managementGroupPolicySetDefinitionResourceId = ManagementGroupPolicySetDefinitionResource.CreateResourceIdentifier(managementGroupId, policySetDefinitionName); - ManagementGroupPolicySetDefinitionResource managementGroupPolicySetDefinition = client.GetManagementGroupPolicySetDefinitionResource(managementGroupPolicySetDefinitionResourceId); - - // invoke the operation - await managementGroupPolicySetDefinition.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // Retrieve a policy set definition at management group level - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicySetDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_GetAtManagementGroup" 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 ManagementGroupPolicySetDefinitionResource created on azure - // for more information of creating ManagementGroupPolicySetDefinitionResource, please refer to the document of ManagementGroupPolicySetDefinitionResource - string managementGroupId = "MyManagementGroup"; - string policySetDefinitionName = "CostManagement"; - ResourceIdentifier managementGroupPolicySetDefinitionResourceId = ManagementGroupPolicySetDefinitionResource.CreateResourceIdentifier(managementGroupId, policySetDefinitionName); - ManagementGroupPolicySetDefinitionResource managementGroupPolicySetDefinition = client.GetManagementGroupPolicySetDefinitionResource(managementGroupPolicySetDefinitionResourceId); - - // invoke the operation - ManagementGroupPolicySetDefinitionResource result = await managementGroupPolicySetDefinition.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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupResource.cs deleted file mode 100644 index 9b86227a43e3..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupResource.cs +++ /dev/null @@ -1,262 +0,0 @@ -// 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.ManagementGroups.Models; - -namespace Azure.ResourceManager.ManagementGroups.Samples -{ - public partial class Sample_ManagementGroupResource - { - // GetManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroup.json - // this example is just showing the usage of "ManagementGroups_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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "20000000-0001-0000-0000-000000000000"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // invoke the operation - string cacheControl = "no-cache"; - ManagementGroupResource result = await managementGroup.GetAsync(cacheControl: cacheControl); - - // 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // GetManagementGroupWithAncestors - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetManagementGroupWithAncestors() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json - // this example is just showing the usage of "ManagementGroups_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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "20000000-0001-0000-0000-00000000000"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // invoke the operation - ManagementGroupExpandType? expand = ManagementGroupExpandType.Ancestors; - string cacheControl = "no-cache"; - ManagementGroupResource result = await managementGroup.GetAsync(expand: expand, cacheControl: cacheControl); - - // 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // GetManagementGroupWithExpand - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetManagementGroupWithExpand() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpand.json - // this example is just showing the usage of "ManagementGroups_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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "20000000-0001-0000-0000-000000000000"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // invoke the operation - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; - string cacheControl = "no-cache"; - ManagementGroupResource result = await managementGroup.GetAsync(expand: expand, cacheControl: cacheControl); - - // 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // GetManagementGroupWithPath - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetManagementGroupWithPath() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithPath.json - // this example is just showing the usage of "ManagementGroups_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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "20000000-0001-0000-0000-000000000000"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // invoke the operation - ManagementGroupExpandType? expand = ManagementGroupExpandType.Path; - string cacheControl = "no-cache"; - ManagementGroupResource result = await managementGroup.GetAsync(expand: expand, cacheControl: cacheControl); - - // 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // GetManagementGroupsWithExpandAndRecurse - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetManagementGroupsWithExpandAndRecurse() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpandAndRecurse.json - // this example is just showing the usage of "ManagementGroups_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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "20000000-0001-0000-0000-000000000000"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // invoke the operation - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; - bool? recurse = true; - string cacheControl = "no-cache"; - ManagementGroupResource result = await managementGroup.GetAsync(expand: expand, recurse: recurse, cacheControl: cacheControl); - - // 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // PatchManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_PatchManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/PatchManagementGroup.json - // this example is just showing the usage of "ManagementGroups_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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "ChildGroup"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // invoke the operation - ManagementGroupPatch patch = new ManagementGroupPatch() - { - DisplayName = "AlternateDisplayName", - ParentGroupId = "/providers/Microsoft.Management/managementGroups/AlternateRootGroup", - }; - string cacheControl = "no-cache"; - ManagementGroupResource result = await managementGroup.UpdateAsync(patch, cacheControl: cacheControl); - - // 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 - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // DeleteManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/DeleteManagementGroup.json - // this example is just showing the usage of "ManagementGroups_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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "GroupToDelete"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // invoke the operation - string cacheControl = "no-cache"; - await managementGroup.DeleteAsync(WaitUntil.Completed, cacheControl: cacheControl); - - Console.WriteLine($"Succeeded"); - } - - // GetDescendants - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetDescendants_GetDescendants() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetDescendants.json - // this example is just showing the usage of "ManagementGroups_GetDescendants" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "20000000-0000-0000-0000-000000000000"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // invoke the operation and iterate over the result - await foreach (DescendantData item in managementGroup.GetDescendantsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionCollection.cs deleted file mode 100644 index 46120df4b84a..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionCollection.cs +++ /dev/null @@ -1,193 +0,0 @@ -// 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.ManagementGroups.Samples -{ - public partial class Sample_ManagementGroupSubscriptionCollection - { - // AddSubscriptionToManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_AddSubscriptionToManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/AddManagementGroupSubscription.json - // this example is just showing the usage of "ManagementGroupSubscriptions_Create" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "Group"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupSubscriptionResource - ManagementGroupSubscriptionCollection collection = managementGroup.GetManagementGroupSubscriptions(); - - // invoke the operation - string subscriptionId = "728bcbe4-8d56-4510-86c2-4921b8beefbc"; - string cacheControl = "no-cache"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subscriptionId, cacheControl: cacheControl); - ManagementGroupSubscriptionResource 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 - ManagementGroupSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // GetSubscriptionFromManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetSubscriptionFromManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetSubscriptionFromManagementGroup.json - // this example is just showing the usage of "ManagementGroupSubscriptions_GetSubscription" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "Group"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupSubscriptionResource - ManagementGroupSubscriptionCollection collection = managementGroup.GetManagementGroupSubscriptions(); - - // invoke the operation - string subscriptionId = "728bcbe4-8d56-4510-86c2-4921b8beefbc"; - string cacheControl = "no-cache"; - ManagementGroupSubscriptionResource result = await collection.GetAsync(subscriptionId, cacheControl: cacheControl); - - // 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 - ManagementGroupSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // GetSubscriptionFromManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetSubscriptionFromManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetSubscriptionFromManagementGroup.json - // this example is just showing the usage of "ManagementGroupSubscriptions_GetSubscription" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "Group"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupSubscriptionResource - ManagementGroupSubscriptionCollection collection = managementGroup.GetManagementGroupSubscriptions(); - - // invoke the operation - string subscriptionId = "728bcbe4-8d56-4510-86c2-4921b8beefbc"; - string cacheControl = "no-cache"; - bool result = await collection.ExistsAsync(subscriptionId, cacheControl: cacheControl); - - Console.WriteLine($"Succeeded: {result}"); - } - - // GetSubscriptionFromManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetSubscriptionFromManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetSubscriptionFromManagementGroup.json - // this example is just showing the usage of "ManagementGroupSubscriptions_GetSubscription" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "Group"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupSubscriptionResource - ManagementGroupSubscriptionCollection collection = managementGroup.GetManagementGroupSubscriptions(); - - // invoke the operation - string subscriptionId = "728bcbe4-8d56-4510-86c2-4921b8beefbc"; - string cacheControl = "no-cache"; - NullableResponse response = await collection.GetIfExistsAsync(subscriptionId, cacheControl: cacheControl); - ManagementGroupSubscriptionResource 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 - ManagementGroupSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // GetAllSubscriptionsFromManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_GetAllSubscriptionsFromManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetAllSubscriptionsFromManagementGroup.json - // this example is just showing the usage of "ManagementGroupSubscriptions_GetSubscriptionsUnderManagementGroup" 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 ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "Group"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); - ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); - - // get the collection of this ManagementGroupSubscriptionResource - ManagementGroupSubscriptionCollection collection = managementGroup.GetManagementGroupSubscriptions(); - - // invoke the operation and iterate over the result - await foreach (ManagementGroupSubscriptionResource 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 - ManagementGroupSubscriptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionResource.cs deleted file mode 100644 index 5fedd97906c0..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionResource.cs +++ /dev/null @@ -1,107 +0,0 @@ -// 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.ManagementGroups.Samples -{ - public partial class Sample_ManagementGroupSubscriptionResource - { - // AddSubscriptionToManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_AddSubscriptionToManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/AddManagementGroupSubscription.json - // this example is just showing the usage of "ManagementGroupSubscriptions_Create" 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 ManagementGroupSubscriptionResource created on azure - // for more information of creating ManagementGroupSubscriptionResource, please refer to the document of ManagementGroupSubscriptionResource - string groupId = "Group"; - string subscriptionId = "728bcbe4-8d56-4510-86c2-4921b8beefbc"; - ResourceIdentifier managementGroupSubscriptionResourceId = ManagementGroupSubscriptionResource.CreateResourceIdentifier(groupId, subscriptionId); - ManagementGroupSubscriptionResource managementGroupSubscription = client.GetManagementGroupSubscriptionResource(managementGroupSubscriptionResourceId); - - // invoke the operation - string cacheControl = "no-cache"; - ArmOperation lro = await managementGroupSubscription.UpdateAsync(WaitUntil.Completed, cacheControl: cacheControl); - ManagementGroupSubscriptionResource 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 - ManagementGroupSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // DeleteSubscriptionFromManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteSubscriptionFromManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/RemoveManagementGroupSubscription.json - // this example is just showing the usage of "ManagementGroupSubscriptions_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 ManagementGroupSubscriptionResource created on azure - // for more information of creating ManagementGroupSubscriptionResource, please refer to the document of ManagementGroupSubscriptionResource - string groupId = "Group"; - string subscriptionId = "728bcbe4-8d56-4510-86c2-4921b8beefbc"; - ResourceIdentifier managementGroupSubscriptionResourceId = ManagementGroupSubscriptionResource.CreateResourceIdentifier(groupId, subscriptionId); - ManagementGroupSubscriptionResource managementGroupSubscription = client.GetManagementGroupSubscriptionResource(managementGroupSubscriptionResourceId); - - // invoke the operation - string cacheControl = "no-cache"; - await managementGroupSubscription.DeleteAsync(WaitUntil.Completed, cacheControl: cacheControl); - - Console.WriteLine($"Succeeded"); - } - - // GetSubscriptionFromManagementGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetSubscriptionFromManagementGroup() - { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetSubscriptionFromManagementGroup.json - // this example is just showing the usage of "ManagementGroupSubscriptions_GetSubscription" 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 ManagementGroupSubscriptionResource created on azure - // for more information of creating ManagementGroupSubscriptionResource, please refer to the document of ManagementGroupSubscriptionResource - string groupId = "Group"; - string subscriptionId = "728bcbe4-8d56-4510-86c2-4921b8beefbc"; - ResourceIdentifier managementGroupSubscriptionResourceId = ManagementGroupSubscriptionResource.CreateResourceIdentifier(groupId, subscriptionId); - ManagementGroupSubscriptionResource managementGroupSubscription = client.GetManagementGroupSubscriptionResource(managementGroupSubscriptionResourceId); - - // invoke the operation - string cacheControl = "no-cache"; - ManagementGroupSubscriptionResource result = await managementGroupSubscription.GetAsync(cacheControl: cacheControl); - - // 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 - ManagementGroupSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockCollection.cs deleted file mode 100644 index da65c233e61e..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockCollection.cs +++ /dev/null @@ -1,186 +0,0 @@ -// 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.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_ManagementLockCollection - { - // Create management lock at scope - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateManagementLockAtScope() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json - // this example is just showing the usage of "ManagementLocks_CreateOrUpdateByScope" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this ManagementLockResource - string scope = "subscriptions/subscriptionId"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagementLockCollection collection = client.GetGenericResource(scopeId).GetManagementLocks(); - - // invoke the operation - string lockName = "testlock"; - ManagementLockData data = new ManagementLockData(ManagementLockLevel.ReadOnly); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, lockName, data); - ManagementLockResource 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 - ManagementLockData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get management lock at scope - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetManagementLockAtScope() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json - // this example is just showing the usage of "ManagementLocks_GetByScope" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this ManagementLockResource - string scope = "subscriptions/subscriptionId"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagementLockCollection collection = client.GetGenericResource(scopeId).GetManagementLocks(); - - // invoke the operation - string lockName = "testlock"; - ManagementLockResource result = await collection.GetAsync(lockName); - - // 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 - ManagementLockData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get management lock at scope - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetManagementLockAtScope() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json - // this example is just showing the usage of "ManagementLocks_GetByScope" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this ManagementLockResource - string scope = "subscriptions/subscriptionId"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagementLockCollection collection = client.GetGenericResource(scopeId).GetManagementLocks(); - - // invoke the operation - string lockName = "testlock"; - bool result = await collection.ExistsAsync(lockName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Get management lock at scope - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetManagementLockAtScope() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json - // this example is just showing the usage of "ManagementLocks_GetByScope" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this ManagementLockResource - string scope = "subscriptions/subscriptionId"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagementLockCollection collection = client.GetGenericResource(scopeId).GetManagementLocks(); - - // invoke the operation - string lockName = "testlock"; - NullableResponse response = await collection.GetIfExistsAsync(lockName); - ManagementLockResource 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 - ManagementLockData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List management locks at scope - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListManagementLocksAtScope() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtScope.json - // this example is just showing the usage of "ManagementLocks_ListByScope" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this ManagementLockResource - string scope = "subscriptions/subscriptionId"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagementLockCollection collection = client.GetGenericResource(scopeId).GetManagementLocks(); - - // invoke the operation and iterate over the result - await foreach (ManagementLockResource 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 - ManagementLockData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockResource.cs deleted file mode 100644 index 85d3877dd71b..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockResource.cs +++ /dev/null @@ -1,106 +0,0 @@ -// 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.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_ManagementLockResource - { - // Create management lock at scope - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateManagementLockAtScope() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json - // this example is just showing the usage of "ManagementLocks_CreateOrUpdateByScope" 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 ManagementLockResource created on azure - // for more information of creating ManagementLockResource, please refer to the document of ManagementLockResource - string scope = "subscriptions/subscriptionId"; - string lockName = "testlock"; - ResourceIdentifier managementLockResourceId = ManagementLockResource.CreateResourceIdentifier(scope, lockName); - ManagementLockResource managementLock = client.GetManagementLockResource(managementLockResourceId); - - // invoke the operation - ManagementLockData data = new ManagementLockData(ManagementLockLevel.ReadOnly); - ArmOperation lro = await managementLock.UpdateAsync(WaitUntil.Completed, data); - ManagementLockResource 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 - ManagementLockData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Delete management lock at scope - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteManagementLockAtScope() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtScope.json - // this example is just showing the usage of "ManagementLocks_DeleteByScope" 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 ManagementLockResource created on azure - // for more information of creating ManagementLockResource, please refer to the document of ManagementLockResource - string scope = "subscriptions/subscriptionId"; - string lockName = "testlock"; - ResourceIdentifier managementLockResourceId = ManagementLockResource.CreateResourceIdentifier(scope, lockName); - ManagementLockResource managementLock = client.GetManagementLockResource(managementLockResourceId); - - // invoke the operation - await managementLock.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // Get management lock at scope - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetManagementLockAtScope() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json - // this example is just showing the usage of "ManagementLocks_GetByScope" 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 ManagementLockResource created on azure - // for more information of creating ManagementLockResource, please refer to the document of ManagementLockResource - string scope = "subscriptions/subscriptionId"; - string lockName = "testlock"; - ResourceIdentifier managementLockResourceId = ManagementLockResource.CreateResourceIdentifier(scope, lockName); - ManagementLockResource managementLock = client.GetManagementLockResource(managementLockResourceId); - - // invoke the operation - ManagementLockResource result = await managementLock.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 - ManagementLockData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentCollection.cs deleted file mode 100644 index 48789d471e74..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentCollection.cs +++ /dev/null @@ -1,1069 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_PolicyAssignmentCollection - { - // Create or update a policy assignment - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignment() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignment.json - // this example is just showing the usage of "PolicyAssignments_Create" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - PolicyAssignmentData data = new PolicyAssignmentData() - { - DisplayName = "Enforce resource naming rules", - PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - Parameters = -{ -["prefix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"DeptA\""), -}, -["suffix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"-LC\""), -}, -}, - Description = "Force resource names to begin with given DeptA and end with -LC", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["assignedBy"] = "Special Someone" - }), - NonComplianceMessages = -{ -new NonComplianceMessage("Resource names must start with 'DeptA' and end with '-LC'.") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyAssignmentName, data); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create or update a policy assignment with a system assigned identity - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithASystemAssignedIdentity() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentWithIdentity.json - // this example is just showing the usage of "PolicyAssignments_Create" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - PolicyAssignmentData data = new PolicyAssignmentData() - { - Location = new AzureLocation("eastus"), - ManagedIdentity = new ManagedServiceIdentity("SystemAssigned"), - DisplayName = "Enforce resource naming rules", - PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - Parameters = -{ -["prefix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"DeptA\""), -}, -["suffix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"-LC\""), -}, -}, - Description = "Force resource names to begin with given DeptA and end with -LC", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["assignedBy"] = "Foo Bar" - }), - EnforcementMode = EnforcementMode.Default, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyAssignmentName, data); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create or update a policy assignment with a user assigned identity - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithAUserAssignedIdentity() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentWithUserAssignedIdentity.json - // this example is just showing the usage of "PolicyAssignments_Create" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - PolicyAssignmentData data = new PolicyAssignmentData() - { - Location = new AzureLocation("eastus"), - ManagedIdentity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity")] = new UserAssignedIdentity(), -}, - }, - DisplayName = "Enforce resource naming rules", - PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - Parameters = -{ -["prefix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"DeptA\""), -}, -["suffix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"-LC\""), -}, -}, - Description = "Force resource names to begin with given DeptA and end with -LC", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["assignedBy"] = "Foo Bar" - }), - EnforcementMode = EnforcementMode.Default, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyAssignmentName, data); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create or update a policy assignment with multiple non-compliance messages - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentNonComplianceMessages.json - // this example is just showing the usage of "PolicyAssignments_Create" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "securityInitAssignment"; - PolicyAssignmentData data = new PolicyAssignmentData() - { - DisplayName = "Enforce security policies", - PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative", - NonComplianceMessages = -{ -new NonComplianceMessage("Resources must comply with all internal security policies. See for more info."),new NonComplianceMessage("Resource names must start with 'DeptA' and end with '-LC'.") -{ -PolicyDefinitionReferenceId = "10420126870854049575", -},new NonComplianceMessage("Storage accounts must have firewall rules configured.") -{ -PolicyDefinitionReferenceId = "8572513655450389710", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyAssignmentName, data); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create or update a policy assignment with overrides - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithOverrides() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentWithOverrides.json - // this example is just showing the usage of "PolicyAssignments_Create" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "CostManagement"; - PolicyAssignmentData data = new PolicyAssignmentData() - { - DisplayName = "Limit the resource location and resource SKU", - PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", - Description = "Limit the resource location and resource SKU", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["assignedBy"] = "Special Someone" - }), - Overrides = -{ -new PolicyOverride() -{ -Kind = PolicyOverrideKind.PolicyEffect, -Value = "Audit", -Selectors = -{ -new ResourceSelectorExpression() -{ -Kind = ResourceSelectorKind.PolicyDefinitionReferenceId, -In = -{ -"Limit_Skus","Limit_Locations" -}, -} -}, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyAssignmentName, data); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create or update a policy assignment with resource selectors - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithResourceSelectors() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentWithResourceSelectors.json - // this example is just showing the usage of "PolicyAssignments_Create" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "CostManagement"; - PolicyAssignmentData data = new PolicyAssignmentData() - { - DisplayName = "Limit the resource location and resource SKU", - PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", - Description = "Limit the resource location and resource SKU", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["assignedBy"] = "Special Someone" - }), - ResourceSelectors = -{ -new ResourceSelector() -{ -Name = "SDPRegions", -Selectors = -{ -new ResourceSelectorExpression() -{ -Kind = ResourceSelectorKind.ResourceLocation, -In = -{ -"eastus2euap","centraluseuap" -}, -} -}, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyAssignmentName, data); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create or update a policy assignment without enforcing policy effect during resource creation or update. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentWithoutEnforcement.json - // this example is just showing the usage of "PolicyAssignments_Create" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - PolicyAssignmentData data = new PolicyAssignmentData() - { - DisplayName = "Enforce resource naming rules", - PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - Parameters = -{ -["prefix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"DeptA\""), -}, -["suffix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"-LC\""), -}, -}, - Description = "Force resource names to begin with given DeptA and end with -LC", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["assignedBy"] = "Special Someone" - }), - EnforcementMode = EnforcementMode.DoNotEnforce, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyAssignmentName, data); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy assignment - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyAssignment() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignment.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - PolicyAssignmentResource result = await collection.GetAsync(policyAssignmentName); - - // 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy assignment - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_RetrieveAPolicyAssignment() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignment.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - bool result = await collection.ExistsAsync(policyAssignmentName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Retrieve a policy assignment - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_RetrieveAPolicyAssignment() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignment.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // Retrieve a policy assignment with a system assigned identity - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - PolicyAssignmentResource result = await collection.GetAsync(policyAssignmentName); - - // 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy assignment with a system assigned identity - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - bool result = await collection.ExistsAsync(policyAssignmentName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Retrieve a policy assignment with a system assigned identity - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // Retrieve a policy assignment with a user assigned identity - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - PolicyAssignmentResource result = await collection.GetAsync(policyAssignmentName); - - // 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy assignment with a user assigned identity - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - bool result = await collection.ExistsAsync(policyAssignmentName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Retrieve a policy assignment with a user assigned identity - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // Retrieve a policy assignment with overrides - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyAssignmentWithOverrides() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "CostManagement"; - PolicyAssignmentResource result = await collection.GetAsync(policyAssignmentName); - - // 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy assignment with overrides - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_RetrieveAPolicyAssignmentWithOverrides() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "CostManagement"; - bool result = await collection.ExistsAsync(policyAssignmentName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Retrieve a policy assignment with overrides - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_RetrieveAPolicyAssignmentWithOverrides() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "CostManagement"; - NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // Retrieve a policy assignment with resource selectors - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyAssignmentWithResourceSelectors() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithResourceSelectors.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "CostManagement"; - PolicyAssignmentResource result = await collection.GetAsync(policyAssignmentName); - - // 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy assignment with resource selectors - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_RetrieveAPolicyAssignmentWithResourceSelectors() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithResourceSelectors.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "CostManagement"; - bool result = await collection.ExistsAsync(policyAssignmentName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Retrieve a policy assignment with resource selectors - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_RetrieveAPolicyAssignmentWithResourceSelectors() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithResourceSelectors.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "CostManagement"; - NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List policy assignments that apply to a resource group - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListPolicyAssignmentsThatApplyToAResourceGroup() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignmentsForResourceGroup.json - // this example is just showing the usage of "PolicyAssignments_ListForResourceGroup" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string resourceGroupName = "TestResourceGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}", subscriptionId, resourceGroupName)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation and iterate over the result - string filter = "atScope()"; - await foreach (PolicyAssignmentResource item in collection.GetAllAsync(filter: filter)) - { - // 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 - PolicyAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - - // List all policy assignments that apply to a resource - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListAllPolicyAssignmentsThatApplyToAResource() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignmentsForResource.json - // this example is just showing the usage of "PolicyAssignments_ListForResource" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string resourceGroupName = "TestResourceGroup"; - string resourceProviderNamespace = "Microsoft.Compute"; - string parentResourcePath = "virtualMachines/MyTestVm"; - string resourceType = "domainNames"; - string resourceName = "MyTestComputer.cloudapp.net"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/{2}/{3}/{4}/{5}", subscriptionId, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation and iterate over the result - await foreach (PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - - // List policy assignments that apply to a management group - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListPolicyAssignmentsThatApplyToAManagementGroup() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignmentsForManagementGroup.json - // this example is just showing the usage of "PolicyAssignments_ListForManagementGroup" 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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string managementGroupId = "TestManagementGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/providers/Microsoft.Management/managementGroups/{0}", managementGroupId)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation and iterate over the result - string filter = "atScope()"; - await foreach (PolicyAssignmentResource item in collection.GetAllAsync(filter: filter)) - { - // 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 - PolicyAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - - // List policy assignments that apply to a subscription - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListPolicyAssignmentsThatApplyToASubscription() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignments.json - // this example is just showing the usage of "PolicyAssignments_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 ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAssignmentResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}", subscriptionId)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation and iterate over the result - string filter = "atScope()"; - await foreach (PolicyAssignmentResource item in collection.GetAllAsync(filter: filter)) - { - // 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 - PolicyAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentResource.cs deleted file mode 100644 index e2d35c224637..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentResource.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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.Models; -using Azure.ResourceManager.Resources.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_PolicyAssignmentResource - { - // Delete a policy assignment - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteAPolicyAssignment() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/deletePolicyAssignment.json - // this example is just showing the usage of "PolicyAssignments_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 PolicyAssignmentResource created on azure - // for more information of creating PolicyAssignmentResource, please refer to the document of PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyAssignmentName = "EnforceNaming"; - ResourceIdentifier policyAssignmentResourceId = PolicyAssignmentResource.CreateResourceIdentifier(scope, policyAssignmentName); - PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); - - // invoke the operation - ArmOperation lro = await policyAssignment.DeleteAsync(WaitUntil.Completed); - PolicyAssignmentResource 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy assignment - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyAssignment() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignment.json - // this example is just showing the usage of "PolicyAssignments_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 PolicyAssignmentResource created on azure - // for more information of creating PolicyAssignmentResource, please refer to the document of PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyAssignmentName = "EnforceNaming"; - ResourceIdentifier policyAssignmentResourceId = PolicyAssignmentResource.CreateResourceIdentifier(scope, policyAssignmentName); - PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); - - // invoke the operation - PolicyAssignmentResource result = await policyAssignment.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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy assignment with a system assigned identity - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json - // this example is just showing the usage of "PolicyAssignments_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 PolicyAssignmentResource created on azure - // for more information of creating PolicyAssignmentResource, please refer to the document of PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyAssignmentName = "EnforceNaming"; - ResourceIdentifier policyAssignmentResourceId = PolicyAssignmentResource.CreateResourceIdentifier(scope, policyAssignmentName); - PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); - - // invoke the operation - PolicyAssignmentResource result = await policyAssignment.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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy assignment with a user assigned identity - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json - // this example is just showing the usage of "PolicyAssignments_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 PolicyAssignmentResource created on azure - // for more information of creating PolicyAssignmentResource, please refer to the document of PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyAssignmentName = "EnforceNaming"; - ResourceIdentifier policyAssignmentResourceId = PolicyAssignmentResource.CreateResourceIdentifier(scope, policyAssignmentName); - PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); - - // invoke the operation - PolicyAssignmentResource result = await policyAssignment.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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy assignment with overrides - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyAssignmentWithOverrides() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json - // this example is just showing the usage of "PolicyAssignments_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 PolicyAssignmentResource created on azure - // for more information of creating PolicyAssignmentResource, please refer to the document of PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyAssignmentName = "CostManagement"; - ResourceIdentifier policyAssignmentResourceId = PolicyAssignmentResource.CreateResourceIdentifier(scope, policyAssignmentName); - PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); - - // invoke the operation - PolicyAssignmentResource result = await policyAssignment.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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy assignment with resource selectors - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyAssignmentWithResourceSelectors() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithResourceSelectors.json - // this example is just showing the usage of "PolicyAssignments_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 PolicyAssignmentResource created on azure - // for more information of creating PolicyAssignmentResource, please refer to the document of PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyAssignmentName = "CostManagement"; - ResourceIdentifier policyAssignmentResourceId = PolicyAssignmentResource.CreateResourceIdentifier(scope, policyAssignmentName); - PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); - - // invoke the operation - PolicyAssignmentResource result = await policyAssignment.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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Update a policy assignment with a system assigned identity - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdateAPolicyAssignmentWithASystemAssignedIdentity() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/updatePolicyAssignmentWithIdentity.json - // this example is just showing the usage of "PolicyAssignments_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 PolicyAssignmentResource created on azure - // for more information of creating PolicyAssignmentResource, please refer to the document of PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyAssignmentName = "EnforceNaming"; - ResourceIdentifier policyAssignmentResourceId = PolicyAssignmentResource.CreateResourceIdentifier(scope, policyAssignmentName); - PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); - - // invoke the operation - PolicyAssignmentPatch patch = new PolicyAssignmentPatch() - { - Location = new AzureLocation("eastus"), - Identity = new ManagedServiceIdentity("SystemAssigned"), - }; - PolicyAssignmentResource result = await policyAssignment.UpdateAsync(patch); - - // 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Update a policy assignment with a user assigned identity - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdateAPolicyAssignmentWithAUserAssignedIdentity() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.json - // this example is just showing the usage of "PolicyAssignments_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 PolicyAssignmentResource created on azure - // for more information of creating PolicyAssignmentResource, please refer to the document of PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyAssignmentName = "EnforceNaming"; - ResourceIdentifier policyAssignmentResourceId = PolicyAssignmentResource.CreateResourceIdentifier(scope, policyAssignmentName); - PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); - - // invoke the operation - PolicyAssignmentPatch patch = new PolicyAssignmentPatch() - { - Location = new AzureLocation("eastus"), - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity")] = new UserAssignedIdentity(), -}, - }, - }; - PolicyAssignmentResource result = await policyAssignment.UpdateAsync(patch); - - // 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Update a policy assignment with overrides - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdateAPolicyAssignmentWithOverrides() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/updatePolicyAssignmentWithOverrides.json - // this example is just showing the usage of "PolicyAssignments_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 PolicyAssignmentResource created on azure - // for more information of creating PolicyAssignmentResource, please refer to the document of PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyAssignmentName = "CostManagement"; - ResourceIdentifier policyAssignmentResourceId = PolicyAssignmentResource.CreateResourceIdentifier(scope, policyAssignmentName); - PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); - - // invoke the operation - PolicyAssignmentPatch patch = new PolicyAssignmentPatch() - { - Overrides = -{ -new PolicyOverride() -{ -Kind = PolicyOverrideKind.PolicyEffect, -Value = "Audit", -Selectors = -{ -new ResourceSelectorExpression() -{ -Kind = ResourceSelectorKind.PolicyDefinitionReferenceId, -In = -{ -"Limit_Skus","Limit_Locations" -}, -} -}, -} -}, - }; - PolicyAssignmentResource result = await policyAssignment.UpdateAsync(patch); - - // 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Update a policy assignment with resource selectors - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdateAPolicyAssignmentWithResourceSelectors() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/updatePolicyAssignmentWithResourceSelectors.json - // this example is just showing the usage of "PolicyAssignments_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 PolicyAssignmentResource created on azure - // for more information of creating PolicyAssignmentResource, please refer to the document of PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyAssignmentName = "CostManagement"; - ResourceIdentifier policyAssignmentResourceId = PolicyAssignmentResource.CreateResourceIdentifier(scope, policyAssignmentName); - PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); - - // invoke the operation - PolicyAssignmentPatch patch = new PolicyAssignmentPatch() - { - ResourceSelectors = -{ -new ResourceSelector() -{ -Name = "SDPRegions", -Selectors = -{ -new ResourceSelectorExpression() -{ -Kind = ResourceSelectorKind.ResourceLocation, -In = -{ -"eastus2euap","centraluseuap" -}, -} -}, -} -}, - }; - PolicyAssignmentResource result = await policyAssignment.UpdateAsync(patch); - - // 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 - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceGroupCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceGroupCollection.cs deleted file mode 100644 index e71623848544..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceGroupCollection.cs +++ /dev/null @@ -1,52 +0,0 @@ -// 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.Resources.Samples -{ - public partial class Sample_ResourceGroupCollection - { - // Create or update a resource group - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAResourceGroup() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/CreateResourceGroup.json - // this example is just showing the usage of "ResourceGroups_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 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 subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this ResourceGroupResource - ResourceGroupCollection collection = subscription.GetResourceGroups(); - - // invoke the operation - string resourceGroupName = "my-resource-group"; - ResourceGroupData data = new ResourceGroupData(new AzureLocation("eastus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceGroupName, data); - ResourceGroupResource 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 - ResourceGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceGroupResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceGroupResource.cs deleted file mode 100644 index 6b90581b371d..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceGroupResource.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_ResourceGroupResource - { - // Force delete all the Virtual Machines and Virtual Machine Scale Sets in a resource group - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_ForceDeleteAllTheVirtualMachinesAndVirtualMachineScaleSetsInAResourceGroup() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/ForceDeleteVMsAndVMSSInResourceGroup.json - // this example is just showing the usage of "ResourceGroups_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 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 = "my-resource-group"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroup = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation - string forceDeletionTypes = "Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets"; - await resourceGroup.DeleteAsync(WaitUntil.Completed, forceDeletionTypes: forceDeletionTypes); - - Console.WriteLine($"Succeeded"); - } - - // Force delete all the Virtual Machines in a resource group - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_ForceDeleteAllTheVirtualMachinesInAResourceGroup() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/ForceDeleteVMsInResourceGroup.json - // this example is just showing the usage of "ResourceGroups_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 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 = "my-resource-group"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroup = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation - string forceDeletionTypes = "Microsoft.Compute/virtualMachines"; - await resourceGroup.DeleteAsync(WaitUntil.Completed, forceDeletionTypes: forceDeletionTypes); - - Console.WriteLine($"Succeeded"); - } - - // Export a resource group - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task ExportTemplate_ExportAResourceGroup() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/ExportResourceGroup.json - // this example is just showing the usage of "ResourceGroups_ExportTemplate" 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 = "my-resource-group"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroup = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation - ExportTemplate exportTemplate = new ExportTemplate() - { - Resources = -{ -"*" -}, - Options = "IncludeParameterDefaultValue,IncludeComments", - }; - ArmOperation lro = await resourceGroup.ExportTemplateAsync(WaitUntil.Completed, exportTemplate); - ResourceGroupExportResult result = lro.Value; - - Console.WriteLine($"Succeeded: {result}"); - } - - // Export a resource group with filtering - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task ExportTemplate_ExportAResourceGroupWithFiltering() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/ExportResourceGroupWithFiltering.json - // this example is just showing the usage of "ResourceGroups_ExportTemplate" 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 = "my-resource-group"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroup = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation - ExportTemplate exportTemplate = new ExportTemplate() - { - Resources = -{ -"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/My.RP/myResourceType/myFirstResource" -}, - Options = "SkipResourceNameParameterization", - }; - ArmOperation lro = await resourceGroup.ExportTemplateAsync(WaitUntil.Completed, exportTemplate); - ResourceGroupExportResult result = lro.Value; - - Console.WriteLine($"Succeeded: {result}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderCollection.cs deleted file mode 100644 index aec9541a88c7..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderCollection.cs +++ /dev/null @@ -1,155 +0,0 @@ -// 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.Resources.Samples -{ - public partial class Sample_ResourceProviderCollection - { - // Get providers. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_GetProviders() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProviders.json - // this example is just showing the usage of "Providers_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 subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this ResourceProviderResource - ResourceProviderCollection collection = subscription.GetResourceProviders(); - - // invoke the operation and iterate over the result - await foreach (ResourceProviderResource 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 - ResourceProviderData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - - // Get provider. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetProvider() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProvider.json - // this example is just showing the usage of "Providers_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 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 subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this ResourceProviderResource - ResourceProviderCollection collection = subscription.GetResourceProviders(); - - // invoke the operation - string resourceProviderNamespace = "Microsoft.TestRP1"; - ResourceProviderResource result = await collection.GetAsync(resourceProviderNamespace); - - // 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 - ResourceProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get provider. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetProvider() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProvider.json - // this example is just showing the usage of "Providers_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 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 subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this ResourceProviderResource - ResourceProviderCollection collection = subscription.GetResourceProviders(); - - // invoke the operation - string resourceProviderNamespace = "Microsoft.TestRP1"; - bool result = await collection.ExistsAsync(resourceProviderNamespace); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Get provider. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetProvider() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProvider.json - // this example is just showing the usage of "Providers_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 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 subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this ResourceProviderResource - ResourceProviderCollection collection = subscription.GetResourceProviders(); - - // invoke the operation - string resourceProviderNamespace = "Microsoft.TestRP1"; - NullableResponse response = await collection.GetIfExistsAsync(resourceProviderNamespace); - ResourceProviderResource 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 - ResourceProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderResource.cs deleted file mode 100644 index d26c4990dfdc..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderResource.cs +++ /dev/null @@ -1,106 +0,0 @@ -// 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.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_ResourceProviderResource - { - // Get provider resource types. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task ProviderPermissions_GetProviderResourceTypes() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProviderPermissions.json - // this example is just showing the usage of "Providers_ProviderPermissions" 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 ResourceProviderResource created on azure - // for more information of creating ResourceProviderResource, please refer to the document of ResourceProviderResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceProviderNamespace = "Microsoft.TestRP"; - ResourceIdentifier resourceProviderResourceId = ResourceProviderResource.CreateResourceIdentifier(subscriptionId, resourceProviderNamespace); - ResourceProviderResource resourceProvider = client.GetResourceProviderResource(resourceProviderResourceId); - - // invoke the operation and iterate over the result - await foreach (ProviderPermission item in resourceProvider.ProviderPermissionsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine($"Succeeded"); - } - - // Get provider. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetProvider() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProvider.json - // this example is just showing the usage of "Providers_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 ResourceProviderResource created on azure - // for more information of creating ResourceProviderResource, please refer to the document of ResourceProviderResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceProviderNamespace = "Microsoft.TestRP1"; - ResourceIdentifier resourceProviderResourceId = ResourceProviderResource.CreateResourceIdentifier(subscriptionId, resourceProviderNamespace); - ResourceProviderResource resourceProvider = client.GetResourceProviderResource(resourceProviderResourceId); - - // invoke the operation - ResourceProviderResource result = await resourceProvider.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 - ResourceProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get provider resource types. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetProviderResourceTypes_GetProviderResourceTypes() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProviderResourceTypes.json - // this example is just showing the usage of "ProviderResourceTypes_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 ResourceProviderResource created on azure - // for more information of creating ResourceProviderResource, please refer to the document of ResourceProviderResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceProviderNamespace = "Microsoft.TestRP"; - ResourceIdentifier resourceProviderResourceId = ResourceProviderResource.CreateResourceIdentifier(subscriptionId, resourceProviderNamespace); - ResourceProviderResource resourceProvider = client.GetResourceProviderResource(resourceProviderResourceId); - - // invoke the operation and iterate over the result - await foreach (ProviderResourceType item in resourceProvider.GetProviderResourceTypesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionCollection.cs deleted file mode 100644 index ca112821c63c..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionCollection.cs +++ /dev/null @@ -1,147 +0,0 @@ -// 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.Resources.Samples -{ - public partial class Sample_SubscriptionCollection - { - // GetASingleSubscription - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetASingleSubscription() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json - // this example is just showing the usage of "Subscriptions_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this SubscriptionResource - SubscriptionCollection collection = tenant.GetSubscriptions(); - - // invoke the operation - string subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; - SubscriptionResource result = await collection.GetAsync(subscriptionId); - - // 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 - SubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // GetASingleSubscription - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetASingleSubscription() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json - // this example is just showing the usage of "Subscriptions_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this SubscriptionResource - SubscriptionCollection collection = tenant.GetSubscriptions(); - - // invoke the operation - string subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; - bool result = await collection.ExistsAsync(subscriptionId); - - Console.WriteLine($"Succeeded: {result}"); - } - - // GetASingleSubscription - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetASingleSubscription() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json - // this example is just showing the usage of "Subscriptions_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this SubscriptionResource - SubscriptionCollection collection = tenant.GetSubscriptions(); - - // invoke the operation - string subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; - NullableResponse response = await collection.GetIfExistsAsync(subscriptionId); - SubscriptionResource 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 - SubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // GetAllSubscriptions - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_GetAllSubscriptions() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscriptions.json - // this example is just showing the usage of "Subscriptions_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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this SubscriptionResource - SubscriptionCollection collection = tenant.GetSubscriptions(); - - // invoke the operation and iterate over the result - await foreach (SubscriptionResource 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 - SubscriptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionCollection.cs deleted file mode 100644 index fb20dadecfb5..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionCollection.cs +++ /dev/null @@ -1,324 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.Resources.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_SubscriptionPolicyDefinitionCollection - { - // Create or update a policy definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_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 SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SubscriptionPolicyDefinitionResource - SubscriptionPolicyDefinitionCollection collection = subscription.GetSubscriptionPolicyDefinitions(); - - // invoke the operation - string policyDefinitionName = "ResourceNaming"; - PolicyDefinitionData data = new PolicyDefinitionData() - { - Mode = "All", - DisplayName = "Enforce resource naming convention", - Description = "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - PolicyRule = BinaryData.FromObjectAsJson(new Dictionary() - { - ["if"] = new Dictionary() - { - ["not"] = new Dictionary() - { - ["field"] = "name", - ["like"] = "[concat(parameters('prefix'), '*', parameters('suffix'))]" - } - }, - ["then"] = new Dictionary() - { - ["effect"] = "deny" - } - }), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Naming" - }), - Parameters = -{ -["prefix"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Prefix", -Description = "Resource name prefix", -}, -}, -["suffix"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Suffix", -Description = "Resource name suffix", -}, -}, -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyDefinitionName, data); - SubscriptionPolicyDefinitionResource 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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create or update a policy definition with advanced parameters - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicyDefinitionWithAdvancedParameters() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json - // this example is just showing the usage of "PolicyDefinitions_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 SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SubscriptionPolicyDefinitionResource - SubscriptionPolicyDefinitionCollection collection = subscription.GetSubscriptionPolicyDefinitions(); - - // invoke the operation - string policyDefinitionName = "EventHubDiagnosticLogs"; - PolicyDefinitionData data = new PolicyDefinitionData() - { - Mode = "Indexed", - DisplayName = "Event Hubs should have diagnostic logging enabled", - Description = "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised", - PolicyRule = BinaryData.FromObjectAsJson(new Dictionary() - { - ["if"] = new Dictionary() - { - ["equals"] = "Microsoft.EventHub/namespaces", - ["field"] = "type" - }, - ["then"] = new Dictionary() - { - ["effect"] = "AuditIfNotExists", - ["details"] = new Dictionary() - { - ["type"] = "Microsoft.Insights/diagnosticSettings", - ["existenceCondition"] = new Dictionary() - { - ["allOf"] = new object[] { new Dictionary() -{ -["equals"] = "true", -["field"] = "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled"}, new Dictionary() -{ -["equals"] = "[parameters('requiredRetentionDays')]", -["field"] = "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days"} } - } - } - } - }), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Event Hub" - }), - Parameters = -{ -["requiredRetentionDays"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.Integer, -AllowedValues = -{ -BinaryData.FromString("\"0\""),BinaryData.FromString("\"30\""),BinaryData.FromString("\"90\""),BinaryData.FromString("\"180\""),BinaryData.FromString("\"365\"") -}, -DefaultValue = BinaryData.FromString("\"365\""), -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Required retention (days)", -Description = "The required diagnostic logs retention in days", -}, -}, -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyDefinitionName, data); - SubscriptionPolicyDefinitionResource 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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_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 SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SubscriptionPolicyDefinitionResource - SubscriptionPolicyDefinitionCollection collection = subscription.GetSubscriptionPolicyDefinitions(); - - // invoke the operation - string policyDefinitionName = "ResourceNaming"; - SubscriptionPolicyDefinitionResource result = await collection.GetAsync(policyDefinitionName); - - // 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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_RetrieveAPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_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 SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SubscriptionPolicyDefinitionResource - SubscriptionPolicyDefinitionCollection collection = subscription.GetSubscriptionPolicyDefinitions(); - - // invoke the operation - string policyDefinitionName = "ResourceNaming"; - bool result = await collection.ExistsAsync(policyDefinitionName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Retrieve a policy definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_RetrieveAPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_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 SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SubscriptionPolicyDefinitionResource - SubscriptionPolicyDefinitionCollection collection = subscription.GetSubscriptionPolicyDefinitions(); - - // invoke the operation - string policyDefinitionName = "ResourceNaming"; - NullableResponse response = await collection.GetIfExistsAsync(policyDefinitionName); - SubscriptionPolicyDefinitionResource 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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List policy definitions by subscription - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListPolicyDefinitionsBySubscription() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitions.json - // this example is just showing the usage of "PolicyDefinitions_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 = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SubscriptionPolicyDefinitionResource - SubscriptionPolicyDefinitionCollection collection = subscription.GetSubscriptionPolicyDefinitions(); - - // invoke the operation and iterate over the result - await foreach (SubscriptionPolicyDefinitionResource 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 - PolicyDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionResource.cs deleted file mode 100644 index dbd65ce018e5..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionResource.cs +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.Resources.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_SubscriptionPolicyDefinitionResource - { - // Create or update a policy definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateOrUpdateAPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_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 SubscriptionPolicyDefinitionResource created on azure - // for more information of creating SubscriptionPolicyDefinitionResource, please refer to the document of SubscriptionPolicyDefinitionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyDefinitionName = "ResourceNaming"; - ResourceIdentifier subscriptionPolicyDefinitionResourceId = SubscriptionPolicyDefinitionResource.CreateResourceIdentifier(subscriptionId, policyDefinitionName); - SubscriptionPolicyDefinitionResource subscriptionPolicyDefinition = client.GetSubscriptionPolicyDefinitionResource(subscriptionPolicyDefinitionResourceId); - - // invoke the operation - PolicyDefinitionData data = new PolicyDefinitionData() - { - Mode = "All", - DisplayName = "Enforce resource naming convention", - Description = "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - PolicyRule = BinaryData.FromObjectAsJson(new Dictionary() - { - ["if"] = new Dictionary() - { - ["not"] = new Dictionary() - { - ["field"] = "name", - ["like"] = "[concat(parameters('prefix'), '*', parameters('suffix'))]" - } - }, - ["then"] = new Dictionary() - { - ["effect"] = "deny" - } - }), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Naming" - }), - Parameters = -{ -["prefix"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Prefix", -Description = "Resource name prefix", -}, -}, -["suffix"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Suffix", -Description = "Resource name suffix", -}, -}, -}, - }; - ArmOperation lro = await subscriptionPolicyDefinition.UpdateAsync(WaitUntil.Completed, data); - SubscriptionPolicyDefinitionResource 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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create or update a policy definition with advanced parameters - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateOrUpdateAPolicyDefinitionWithAdvancedParameters() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json - // this example is just showing the usage of "PolicyDefinitions_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 SubscriptionPolicyDefinitionResource created on azure - // for more information of creating SubscriptionPolicyDefinitionResource, please refer to the document of SubscriptionPolicyDefinitionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyDefinitionName = "EventHubDiagnosticLogs"; - ResourceIdentifier subscriptionPolicyDefinitionResourceId = SubscriptionPolicyDefinitionResource.CreateResourceIdentifier(subscriptionId, policyDefinitionName); - SubscriptionPolicyDefinitionResource subscriptionPolicyDefinition = client.GetSubscriptionPolicyDefinitionResource(subscriptionPolicyDefinitionResourceId); - - // invoke the operation - PolicyDefinitionData data = new PolicyDefinitionData() - { - Mode = "Indexed", - DisplayName = "Event Hubs should have diagnostic logging enabled", - Description = "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised", - PolicyRule = BinaryData.FromObjectAsJson(new Dictionary() - { - ["if"] = new Dictionary() - { - ["equals"] = "Microsoft.EventHub/namespaces", - ["field"] = "type" - }, - ["then"] = new Dictionary() - { - ["effect"] = "AuditIfNotExists", - ["details"] = new Dictionary() - { - ["type"] = "Microsoft.Insights/diagnosticSettings", - ["existenceCondition"] = new Dictionary() - { - ["allOf"] = new object[] { new Dictionary() -{ -["equals"] = "true", -["field"] = "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled"}, new Dictionary() -{ -["equals"] = "[parameters('requiredRetentionDays')]", -["field"] = "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days"} } - } - } - } - }), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Event Hub" - }), - Parameters = -{ -["requiredRetentionDays"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.Integer, -AllowedValues = -{ -BinaryData.FromString("\"0\""),BinaryData.FromString("\"30\""),BinaryData.FromString("\"90\""),BinaryData.FromString("\"180\""),BinaryData.FromString("\"365\"") -}, -DefaultValue = BinaryData.FromString("\"365\""), -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Required retention (days)", -Description = "The required diagnostic logs retention in days", -}, -}, -}, - }; - ArmOperation lro = await subscriptionPolicyDefinition.UpdateAsync(WaitUntil.Completed, data); - SubscriptionPolicyDefinitionResource 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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Delete a policy definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteAPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_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 SubscriptionPolicyDefinitionResource created on azure - // for more information of creating SubscriptionPolicyDefinitionResource, please refer to the document of SubscriptionPolicyDefinitionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyDefinitionName = "ResourceNaming"; - ResourceIdentifier subscriptionPolicyDefinitionResourceId = SubscriptionPolicyDefinitionResource.CreateResourceIdentifier(subscriptionId, policyDefinitionName); - SubscriptionPolicyDefinitionResource subscriptionPolicyDefinition = client.GetSubscriptionPolicyDefinitionResource(subscriptionPolicyDefinitionResourceId); - - // invoke the operation - await subscriptionPolicyDefinition.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // Retrieve a policy definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_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 SubscriptionPolicyDefinitionResource created on azure - // for more information of creating SubscriptionPolicyDefinitionResource, please refer to the document of SubscriptionPolicyDefinitionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyDefinitionName = "ResourceNaming"; - ResourceIdentifier subscriptionPolicyDefinitionResourceId = SubscriptionPolicyDefinitionResource.CreateResourceIdentifier(subscriptionId, policyDefinitionName); - SubscriptionPolicyDefinitionResource subscriptionPolicyDefinition = client.GetSubscriptionPolicyDefinitionResource(subscriptionPolicyDefinitionResourceId); - - // invoke the operation - SubscriptionPolicyDefinitionResource result = await subscriptionPolicyDefinition.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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionCollection.cs deleted file mode 100644 index dd21c53ab4de..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionCollection.cs +++ /dev/null @@ -1,331 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.Resources.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_SubscriptionPolicySetDefinitionCollection - { - // Create or update a policy set definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_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 SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SubscriptionPolicySetDefinitionResource - SubscriptionPolicySetDefinitionCollection collection = subscription.GetSubscriptionPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "CostManagement"; - PolicySetDefinitionData data = new PolicySetDefinitionData() - { - DisplayName = "Cost Management", - Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Cost Management" - }), - Parameters = -{ -["namePrefix"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.String, -DefaultValue = BinaryData.FromString("\"myPrefix\""), -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Prefix to enforce on resource names", -}, -}, -}, - PolicyDefinitions = -{ -new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") -{ -Parameters = -{ -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, -}, -PolicyDefinitionReferenceId = "Limit_Skus", -},new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") -{ -Parameters = -{ -["prefix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"[parameters('namePrefix')]\""), -}, -["suffix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policySetDefinitionName, data); - SubscriptionPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create or update a policy set definition with groups - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAPolicySetDefinitionWithGroups() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json - // this example is just showing the usage of "PolicySetDefinitions_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 SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SubscriptionPolicySetDefinitionResource - SubscriptionPolicySetDefinitionCollection collection = subscription.GetSubscriptionPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "CostManagement"; - PolicySetDefinitionData data = new PolicySetDefinitionData() - { - DisplayName = "Cost Management", - Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Cost Management" - }), - PolicyDefinitions = -{ -new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") -{ -Parameters = -{ -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, -}, -PolicyDefinitionReferenceId = "Limit_Skus", -GroupNames = -{ -"CostSaving" -}, -},new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") -{ -Parameters = -{ -["prefix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"DeptA\""), -}, -["suffix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", -GroupNames = -{ -"Organizational" -}, -} -}, - PolicyDefinitionGroups = -{ -new PolicyDefinitionGroup("CostSaving") -{ -DisplayName = "Cost Management Policies", -Description = "Policies designed to control spend within a subscription.", -},new PolicyDefinitionGroup("Organizational") -{ -DisplayName = "Organizational Policies", -Description = "Policies that help enforce resource organization standards within a subscription.", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policySetDefinitionName, data); - SubscriptionPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy set definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_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 SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SubscriptionPolicySetDefinitionResource - SubscriptionPolicySetDefinitionCollection collection = subscription.GetSubscriptionPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "CostManagement"; - SubscriptionPolicySetDefinitionResource result = await collection.GetAsync(policySetDefinitionName); - - // 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a policy set definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_RetrieveAPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_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 SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SubscriptionPolicySetDefinitionResource - SubscriptionPolicySetDefinitionCollection collection = subscription.GetSubscriptionPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "CostManagement"; - bool result = await collection.ExistsAsync(policySetDefinitionName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Retrieve a policy set definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_RetrieveAPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_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 SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SubscriptionPolicySetDefinitionResource - SubscriptionPolicySetDefinitionCollection collection = subscription.GetSubscriptionPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "CostManagement"; - NullableResponse response = await collection.GetIfExistsAsync(policySetDefinitionName); - SubscriptionPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List policy set definitions - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListPolicySetDefinitions() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitions.json - // this example is just showing the usage of "PolicySetDefinitions_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 = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SubscriptionPolicySetDefinitionResource - SubscriptionPolicySetDefinitionCollection collection = subscription.GetSubscriptionPolicySetDefinitions(); - - // invoke the operation and iterate over the result - await foreach (SubscriptionPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionResource.cs deleted file mode 100644 index 6ecdcdabf179..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionResource.cs +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.Resources.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_SubscriptionPolicySetDefinitionResource - { - // Create or update a policy set definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateOrUpdateAPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_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 SubscriptionPolicySetDefinitionResource created on azure - // for more information of creating SubscriptionPolicySetDefinitionResource, please refer to the document of SubscriptionPolicySetDefinitionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policySetDefinitionName = "CostManagement"; - ResourceIdentifier subscriptionPolicySetDefinitionResourceId = SubscriptionPolicySetDefinitionResource.CreateResourceIdentifier(subscriptionId, policySetDefinitionName); - SubscriptionPolicySetDefinitionResource subscriptionPolicySetDefinition = client.GetSubscriptionPolicySetDefinitionResource(subscriptionPolicySetDefinitionResourceId); - - // invoke the operation - PolicySetDefinitionData data = new PolicySetDefinitionData() - { - DisplayName = "Cost Management", - Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Cost Management" - }), - Parameters = -{ -["namePrefix"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.String, -DefaultValue = BinaryData.FromString("\"myPrefix\""), -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Prefix to enforce on resource names", -}, -}, -}, - PolicyDefinitions = -{ -new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") -{ -Parameters = -{ -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, -}, -PolicyDefinitionReferenceId = "Limit_Skus", -},new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") -{ -Parameters = -{ -["prefix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"[parameters('namePrefix')]\""), -}, -["suffix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", -} -}, - }; - ArmOperation lro = await subscriptionPolicySetDefinition.UpdateAsync(WaitUntil.Completed, data); - SubscriptionPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create or update a policy set definition with groups - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateOrUpdateAPolicySetDefinitionWithGroups() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json - // this example is just showing the usage of "PolicySetDefinitions_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 SubscriptionPolicySetDefinitionResource created on azure - // for more information of creating SubscriptionPolicySetDefinitionResource, please refer to the document of SubscriptionPolicySetDefinitionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policySetDefinitionName = "CostManagement"; - ResourceIdentifier subscriptionPolicySetDefinitionResourceId = SubscriptionPolicySetDefinitionResource.CreateResourceIdentifier(subscriptionId, policySetDefinitionName); - SubscriptionPolicySetDefinitionResource subscriptionPolicySetDefinition = client.GetSubscriptionPolicySetDefinitionResource(subscriptionPolicySetDefinitionResourceId); - - // invoke the operation - PolicySetDefinitionData data = new PolicySetDefinitionData() - { - DisplayName = "Cost Management", - Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Cost Management" - }), - PolicyDefinitions = -{ -new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") -{ -Parameters = -{ -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, -}, -PolicyDefinitionReferenceId = "Limit_Skus", -GroupNames = -{ -"CostSaving" -}, -},new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") -{ -Parameters = -{ -["prefix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"DeptA\""), -}, -["suffix"] = new ArmPolicyParameterValue() -{ -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", -GroupNames = -{ -"Organizational" -}, -} -}, - PolicyDefinitionGroups = -{ -new PolicyDefinitionGroup("CostSaving") -{ -DisplayName = "Cost Management Policies", -Description = "Policies designed to control spend within a subscription.", -},new PolicyDefinitionGroup("Organizational") -{ -DisplayName = "Organizational Policies", -Description = "Policies that help enforce resource organization standards within a subscription.", -} -}, - }; - ArmOperation lro = await subscriptionPolicySetDefinition.UpdateAsync(WaitUntil.Completed, data); - SubscriptionPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Delete a policy set definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteAPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_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 SubscriptionPolicySetDefinitionResource created on azure - // for more information of creating SubscriptionPolicySetDefinitionResource, please refer to the document of SubscriptionPolicySetDefinitionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policySetDefinitionName = "CostManagement"; - ResourceIdentifier subscriptionPolicySetDefinitionResourceId = SubscriptionPolicySetDefinitionResource.CreateResourceIdentifier(subscriptionId, policySetDefinitionName); - SubscriptionPolicySetDefinitionResource subscriptionPolicySetDefinition = client.GetSubscriptionPolicySetDefinitionResource(subscriptionPolicySetDefinitionResourceId); - - // invoke the operation - await subscriptionPolicySetDefinition.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // Retrieve a policy set definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveAPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_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 SubscriptionPolicySetDefinitionResource created on azure - // for more information of creating SubscriptionPolicySetDefinitionResource, please refer to the document of SubscriptionPolicySetDefinitionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policySetDefinitionName = "CostManagement"; - ResourceIdentifier subscriptionPolicySetDefinitionResourceId = SubscriptionPolicySetDefinitionResource.CreateResourceIdentifier(subscriptionId, policySetDefinitionName); - SubscriptionPolicySetDefinitionResource subscriptionPolicySetDefinition = client.GetSubscriptionPolicySetDefinitionResource(subscriptionPolicySetDefinitionResourceId); - - // invoke the operation - SubscriptionPolicySetDefinitionResource result = await subscriptionPolicySetDefinition.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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionResource.cs deleted file mode 100644 index 768a8afe27e3..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionResource.cs +++ /dev/null @@ -1,136 +0,0 @@ -// 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.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_SubscriptionResource - { - // GetLocationsWithASubscriptionId - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetLocations_GetLocationsWithASubscriptionId() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetLocations.json - // this example is just showing the usage of "Subscriptions_ListLocations" 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 = "a1ffc958-d2c7-493e-9f1e-125a0477f536"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (LocationExpanded item in subscription.GetLocationsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine($"Succeeded"); - } - - // GetLocationsWithExtendedLocations - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetLocations_GetLocationsWithExtendedLocations() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetLocationsWithExtendedLocations.json - // this example is just showing the usage of "Subscriptions_ListLocations" 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 = "a1ffc958-d2c7-493e-9f1e-125a0477f536"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - bool? includeExtendedLocations = true; - await foreach (LocationExpanded item in subscription.GetLocationsAsync(includeExtendedLocations: includeExtendedLocations)) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine($"Succeeded"); - } - - // GetASingleSubscription - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetASingleSubscription() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json - // this example is just showing the usage of "Subscriptions_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 SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - SubscriptionResource result = await subscription.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 - SubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // List subscription Features - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetFeatures_ListSubscriptionFeatures() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listSubscriptionFeatures.json - // this example is just showing the usage of "Features_ListAll" 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 = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (FeatureResource item in subscription.GetFeaturesAsync()) - { - // 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 - FeatureData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TagResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TagResource.cs deleted file mode 100644 index 5d5861397a91..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TagResource.cs +++ /dev/null @@ -1,280 +0,0 @@ -// 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.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_TagResource - { - // Update tags on a resource - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_UpdateTagsOnAResource() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/PutTagsResource.json - // this example is just showing the usage of "Tags_CreateOrUpdateAtScope" 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 TagResource created on azure - // for more information of creating TagResource, please refer to the document of TagResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"; - ResourceIdentifier tagResourceId = TagResource.CreateResourceIdentifier(scope); - TagResource tagResource = client.GetTagResource(tagResourceId); - - // invoke the operation - TagResourceData data = new TagResourceData(new Tag() - { - TagValues = -{ -["tagKey1"] = "tag-value-1", -["tagKey2"] = "tag-value-2", -}, - }); - ArmOperation lro = await tagResource.CreateOrUpdateAsync(WaitUntil.Completed, data); - TagResource 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 - TagResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Update tags on a subscription - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_UpdateTagsOnASubscription() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/PutTagsSubscription.json - // this example is just showing the usage of "Tags_CreateOrUpdateAtScope" 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 TagResource created on azure - // for more information of creating TagResource, please refer to the document of TagResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier tagResourceId = TagResource.CreateResourceIdentifier(scope); - TagResource tagResource = client.GetTagResource(tagResourceId); - - // invoke the operation - TagResourceData data = new TagResourceData(new Tag() - { - TagValues = -{ -["tagKey1"] = "tag-value-1", -["tagKey2"] = "tag-value-2", -}, - }); - ArmOperation lro = await tagResource.CreateOrUpdateAsync(WaitUntil.Completed, data); - TagResource 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 - TagResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Update tags on a resource - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdateTagsOnAResource() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/PatchTagsResource.json - // this example is just showing the usage of "Tags_UpdateAtScope" 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 TagResource created on azure - // for more information of creating TagResource, please refer to the document of TagResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"; - ResourceIdentifier tagResourceId = TagResource.CreateResourceIdentifier(scope); - TagResource tagResource = client.GetTagResource(tagResourceId); - - // invoke the operation - TagResourcePatch patch = new TagResourcePatch() - { - PatchMode = TagPatchMode.Replace, - TagValues = -{ -["tagKey1"] = "tag-value-1", -["tagKey2"] = "tag-value-2", -}, - }; - ArmOperation lro = await tagResource.UpdateAsync(WaitUntil.Completed, patch); - TagResource 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 - TagResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Update tags on a subscription - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdateTagsOnASubscription() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/PatchTagsSubscription.json - // this example is just showing the usage of "Tags_UpdateAtScope" 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 TagResource created on azure - // for more information of creating TagResource, please refer to the document of TagResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier tagResourceId = TagResource.CreateResourceIdentifier(scope); - TagResource tagResource = client.GetTagResource(tagResourceId); - - // invoke the operation - TagResourcePatch patch = new TagResourcePatch() - { - PatchMode = TagPatchMode.Replace, - TagValues = -{ -["tagKey1"] = "tag-value-1", -["tagKey2"] = "tag-value-2", -}, - }; - ArmOperation lro = await tagResource.UpdateAsync(WaitUntil.Completed, patch); - TagResource 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 - TagResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get tags on a resource - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetTagsOnAResource() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetTagsResource.json - // this example is just showing the usage of "Tags_GetAtScope" 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 TagResource created on azure - // for more information of creating TagResource, please refer to the document of TagResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"; - ResourceIdentifier tagResourceId = TagResource.CreateResourceIdentifier(scope); - TagResource tagResource = client.GetTagResource(tagResourceId); - - // invoke the operation - TagResource result = await tagResource.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 - TagResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get tags on a subscription - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetTagsOnASubscription() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetTagsSubscription.json - // this example is just showing the usage of "Tags_GetAtScope" 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 TagResource created on azure - // for more information of creating TagResource, please refer to the document of TagResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier tagResourceId = TagResource.CreateResourceIdentifier(scope); - TagResource tagResource = client.GetTagResource(tagResourceId); - - // invoke the operation - TagResource result = await tagResource.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 - TagResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Update tags on a resource - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_UpdateTagsOnAResource() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/DeleteTagsResource.json - // this example is just showing the usage of "Tags_DeleteAtScope" 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 TagResource created on azure - // for more information of creating TagResource, please refer to the document of TagResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"; - ResourceIdentifier tagResourceId = TagResource.CreateResourceIdentifier(scope); - TagResource tagResource = client.GetTagResource(tagResourceId); - - // invoke the operation - await tagResource.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // Update tags on a subscription - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_UpdateTagsOnASubscription() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/DeleteTagsSubscription.json - // this example is just showing the usage of "Tags_DeleteAtScope" 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 TagResource created on azure - // for more information of creating TagResource, please refer to the document of TagResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier tagResourceId = TagResource.CreateResourceIdentifier(scope); - TagResource tagResource = client.GetTagResource(tagResourceId); - - // invoke the operation - await tagResource.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantCollection.cs deleted file mode 100644 index 49efd4e82a8a..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantCollection.cs +++ /dev/null @@ -1,67 +0,0 @@ -// 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.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_TenantCollection - { - // GetAllTenants - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_GetAllTenants() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetTenants.json - // this example is just showing the usage of "Tenants_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); - - TenantCollection collection = client.GetTenants(); - - // invoke the operation and iterate over the result - await foreach (TenantResource 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 - TenantData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - - // CheckValidityForAResourceName - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CheckResourceName_CheckValidityForAResourceName() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/CheckResourceName.json - // this example is just showing the usage of "checkResourceName" 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); - - TenantCollection collection = client.GetTenants(); - - // invoke the operation - ResourceNameValidationResult result = await collection.CheckResourceNameAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicyDefinitionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicyDefinitionCollection.cs deleted file mode 100644 index bec219465094..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicyDefinitionCollection.cs +++ /dev/null @@ -1,147 +0,0 @@ -// 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.Resources.Samples -{ - public partial class Sample_TenantPolicyDefinitionCollection - { - // Retrieve a built-in policy definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveABuiltInPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltinPolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_GetBuiltIn" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantPolicyDefinitionResource - TenantPolicyDefinitionCollection collection = tenant.GetTenantPolicyDefinitions(); - - // invoke the operation - string policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; - TenantPolicyDefinitionResource result = await collection.GetAsync(policyDefinitionName); - - // 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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a built-in policy definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_RetrieveABuiltInPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltinPolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_GetBuiltIn" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantPolicyDefinitionResource - TenantPolicyDefinitionCollection collection = tenant.GetTenantPolicyDefinitions(); - - // invoke the operation - string policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; - bool result = await collection.ExistsAsync(policyDefinitionName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Retrieve a built-in policy definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_RetrieveABuiltInPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltinPolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_GetBuiltIn" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantPolicyDefinitionResource - TenantPolicyDefinitionCollection collection = tenant.GetTenantPolicyDefinitions(); - - // invoke the operation - string policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; - NullableResponse response = await collection.GetIfExistsAsync(policyDefinitionName); - TenantPolicyDefinitionResource 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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List built-in policy definitions - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListBuiltInPolicyDefinitions() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicyDefinitions.json - // this example is just showing the usage of "PolicyDefinitions_ListBuiltIn" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantPolicyDefinitionResource - TenantPolicyDefinitionCollection collection = tenant.GetTenantPolicyDefinitions(); - - // invoke the operation and iterate over the result - await foreach (TenantPolicyDefinitionResource 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 - PolicyDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicyDefinitionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicyDefinitionResource.cs deleted file mode 100644 index c36fee50c19e..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicyDefinitionResource.cs +++ /dev/null @@ -1,46 +0,0 @@ -// 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.Resources.Samples -{ - public partial class Sample_TenantPolicyDefinitionResource - { - // Retrieve a built-in policy definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveABuiltInPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltinPolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_GetBuiltIn" 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 TenantPolicyDefinitionResource created on azure - // for more information of creating TenantPolicyDefinitionResource, please refer to the document of TenantPolicyDefinitionResource - string policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; - ResourceIdentifier tenantPolicyDefinitionResourceId = TenantPolicyDefinitionResource.CreateResourceIdentifier(policyDefinitionName); - TenantPolicyDefinitionResource tenantPolicyDefinition = client.GetTenantPolicyDefinitionResource(tenantPolicyDefinitionResourceId); - - // invoke the operation - TenantPolicyDefinitionResource result = await tenantPolicyDefinition.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 - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicySetDefinitionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicySetDefinitionCollection.cs deleted file mode 100644 index 5763ce292e7b..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicySetDefinitionCollection.cs +++ /dev/null @@ -1,147 +0,0 @@ -// 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.Resources.Samples -{ - public partial class Sample_TenantPolicySetDefinitionCollection - { - // Retrieve a built-in policy set definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveABuiltInPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltInPolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_GetBuiltIn" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantPolicySetDefinitionResource - TenantPolicySetDefinitionCollection collection = tenant.GetTenantPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; - TenantPolicySetDefinitionResource result = await collection.GetAsync(policySetDefinitionName); - - // 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Retrieve a built-in policy set definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_RetrieveABuiltInPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltInPolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_GetBuiltIn" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantPolicySetDefinitionResource - TenantPolicySetDefinitionCollection collection = tenant.GetTenantPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; - bool result = await collection.ExistsAsync(policySetDefinitionName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Retrieve a built-in policy set definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_RetrieveABuiltInPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltInPolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_GetBuiltIn" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantPolicySetDefinitionResource - TenantPolicySetDefinitionCollection collection = tenant.GetTenantPolicySetDefinitions(); - - // invoke the operation - string policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; - NullableResponse response = await collection.GetIfExistsAsync(policySetDefinitionName); - TenantPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List built-in policy set definitions - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListBuiltInPolicySetDefinitions() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicySetDefinitions.json - // this example is just showing the usage of "PolicySetDefinitions_ListBuiltIn" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantPolicySetDefinitionResource - TenantPolicySetDefinitionCollection collection = tenant.GetTenantPolicySetDefinitions(); - - // invoke the operation and iterate over the result - await foreach (TenantPolicySetDefinitionResource 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 - PolicySetDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicySetDefinitionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicySetDefinitionResource.cs deleted file mode 100644 index 92efdce89b79..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicySetDefinitionResource.cs +++ /dev/null @@ -1,46 +0,0 @@ -// 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.Resources.Samples -{ - public partial class Sample_TenantPolicySetDefinitionResource - { - // Retrieve a built-in policy set definition - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_RetrieveABuiltInPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltInPolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_GetBuiltIn" 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 TenantPolicySetDefinitionResource created on azure - // for more information of creating TenantPolicySetDefinitionResource, please refer to the document of TenantPolicySetDefinitionResource - string policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; - ResourceIdentifier tenantPolicySetDefinitionResourceId = TenantPolicySetDefinitionResource.CreateResourceIdentifier(policySetDefinitionName); - TenantPolicySetDefinitionResource tenantPolicySetDefinition = client.GetTenantPolicySetDefinitionResource(tenantPolicySetDefinitionResourceId); - - // invoke the operation - TenantPolicySetDefinitionResource result = await tenantPolicySetDefinition.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 - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantResource.cs deleted file mode 100644 index 64da914de535..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantResource.cs +++ /dev/null @@ -1,43 +0,0 @@ -// 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.Models; - -namespace Azure.ResourceManager.Resources.Samples -{ - public partial class Sample_TenantResource - { - // Get a resource provider at tenant scope - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetTenantResourceProvider_GetAResourceProviderAtTenantScope() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetNamedProviderAtTenant.json - // this example is just showing the usage of "Providers_GetAtTenantScope" 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 TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation - string resourceProviderNamespace = "Microsoft.Storage"; - string expand = "resourceTypes/aliases"; - TenantResourceProvider result = await tenant.GetTenantResourceProviderAsync(resourceProviderNamespace, expand: expand); - - Console.WriteLine($"Succeeded: {result}"); - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/autorest.md b/sdk/resourcemanager/Azure.ResourceManager/src/autorest.md index 84df38f95d5a..ae646574ff8d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/autorest.md +++ b/sdk/resourcemanager/Azure.ResourceManager/src/autorest.md @@ -36,8 +36,8 @@ sample-gen: clear-output-folder: true namespace: Azure.ResourceManager input-file: - - https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/common-types/resource-management/v3/types.json - - https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/common-types/resource-management/v4/managedidentity.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/common-types/resource-management/v3/types.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/common-types/resource-management/v4/managedidentity.json format-by-name-rules: 'tenantId': 'uuid' @@ -179,14 +179,14 @@ sample-gen: namespace: Azure.ResourceManager.Resources title: ResourceManagementClient input-file: - - https://github.com/Azure/azure-rest-api-specs/blob/817861452040bf29d14b57ac7418560e4680e06e/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/policyAssignments.json - - https://github.com/Azure/azure-rest-api-specs/blob/90a65cb3135d42438a381eb8bb5461a2b99b199f/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/policyDefinitions.json - - https://github.com/Azure/azure-rest-api-specs/blob/90a65cb3135d42438a381eb8bb5461a2b99b199f/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/policySetDefinitions.json - - https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/dataPolicyManifests.json - - https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/locks.json - - https://github.com/Azure/azure-rest-api-specs/blob/90a65cb3135d42438a381eb8bb5461a2b99b199f/specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/resources.json - - https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/subscriptions.json - - https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/features.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/policyAssignments.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/policyDefinitions.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/policySetDefinitions.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/dataPolicyManifests.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/locks.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/resources.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/subscriptions.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/features.json list-exception: - /{resourceId} @@ -695,7 +695,7 @@ sample-gen: namespace: Azure.ResourceManager.ManagementGroups title: ManagementClient input-file: - - https://github.com/Azure/azure-rest-api-specs/blob/90a65cb3135d42438a381eb8bb5461a2b99b199f/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/management.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/management.json request-path-to-parent: /providers/Microsoft.Management/checkNameAvailability: /providers/Microsoft.Management/managementGroups/{groupId} /providers/Microsoft.Management/getEntities: /providers/Microsoft.Management/managementGroups/{groupId} diff --git a/sdk/resources/Azure.ResourceManager.Resources/src/autorest.md b/sdk/resources/Azure.ResourceManager.Resources/src/autorest.md index f1ee87d6e5a3..e84481b99faf 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/src/autorest.md +++ b/sdk/resources/Azure.ResourceManager.Resources/src/autorest.md @@ -348,8 +348,8 @@ These settings apply only when `--tag=package-resources-2022-04` is specified on ```yaml $(tag) == 'package-resources-2022-04' input-file: - - https://github.com/Azure/azure-rest-api-specs/blob/90a65cb3135d42438a381eb8bb5461a2b99b199f/specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/templateSpecs.json - - https://github.com/Azure/azure-rest-api-specs/blob/90a65cb3135d42438a381eb8bb5461a2b99b199f/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/deploymentScripts.json - - https://github.com/Azure/azure-rest-api-specs/blob/90a65cb3135d42438a381eb8bb5461a2b99b199f/specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/resources.json - - https://github.com/Azure/azure-rest-api-specs/blob/90a65cb3135d42438a381eb8bb5461a2b99b199f/specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/managedapplications.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/templateSpecs.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/deploymentScripts.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/resources.json + - https://github.com/Azure/azure-rest-api-specs/blob/7a9a10771d120ce169debf736ca808bef2084562/specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/managedapplications.json ```