From 29fc5193f8e6c2bccbed92840b814307278064be Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Fri, 14 Jul 2023 16:04:44 +0800 Subject: [PATCH 1/2] support generate samples for ArmResourceExtension's operation --- .../Samples/Sample_ArmResourceExtensions.cs | 161 ++++++++++++++++++ .../samples/autorest.tests.md | 7 - 2 files changed, 161 insertions(+), 7 deletions(-) create mode 100644 sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ArmResourceExtensions.cs diff --git a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ArmResourceExtensions.cs b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ArmResourceExtensions.cs new file mode 100644 index 000000000000..e8d81f551e21 --- /dev/null +++ b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ArmResourceExtensions.cs @@ -0,0 +1,161 @@ +// 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; +using Azure.ResourceManager.ResourceHealth; +using Azure.ResourceManager.ResourceHealth.Models; + +namespace Azure.ResourceManager.ResourceHealth.Samples +{ + public partial class Sample_ArmResourceExtensions + { + // GetCurrentHealthByResource + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAvailabilityStatus_GetCurrentHealthByResource() + { + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/stable/2022-10-01/examples/AvailabilityStatus_GetByResource.json + // this example is just showing the usage of "AvailabilityStatuses_GetByResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // invoke the operation + string resourceUri = "resourceUri"; + ResourceIdentifier scope = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + string expand = "recommendedactions"; + ResourceHealthAvailabilityStatus result = await client.GetAvailabilityStatusAsync(scope, expand: expand); + + Console.WriteLine($"Succeeded: {result}"); + } + + // GetHealthHistoryByResource + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAvailabilityStatuses_GetHealthHistoryByResource() + { + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/stable/2022-10-01/examples/AvailabilityStatuses_List.json + // this example is just showing the usage of "AvailabilityStatuses_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); + + // invoke the operation and iterate over the result + string resourceUri = "resourceUri"; + ResourceIdentifier scope = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + await foreach (ResourceHealthAvailabilityStatus item in client.GetAvailabilityStatusesAsync(scope)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // ListEventsBySingleResource + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetHealthEventsOfSingleResource_ListEventsBySingleResource() + { + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/stable/2022-10-01/examples/Events_ListBySingleResource.json + // this example is just showing the usage of "Events_ListBySingleResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // invoke the operation and iterate over the result + string resourceUri = "subscriptions/4abcdefgh-ijkl-mnop-qrstuvwxyz/resourceGroups/rhctestenv/providers/Microsoft.Compute/virtualMachines/rhctestenvV1PI"; + ResourceIdentifier scope = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + await foreach (ResourceHealthEventData item in client.GetHealthEventsOfSingleResourceAsync(scope)) + { + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {item.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // GetChildCurrentHealthByResource + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAvailabilityStatusOfChildResource_GetChildCurrentHealthByResource() + { + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/stable/2022-10-01/examples/ChildAvailabilityStatus_GetByResource.json + // this example is just showing the usage of "ChildAvailabilityStatuses_GetByResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // invoke the operation + string resourceUri = "subscriptions/227b734f-e14f-4de6-b7fc-3190c21e69f6/resourceGroups/JUHACKETRHCTEST/providers/Microsoft.Compute/virtualMachineScaleSets/rhctest/virtualMachines/4"; + ResourceIdentifier scope = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + string expand = "recommendedactions"; + ResourceHealthAvailabilityStatus result = await client.GetAvailabilityStatusOfChildResourceAsync(scope, expand: expand); + + Console.WriteLine($"Succeeded: {result}"); + } + + // GetChildHealthHistoryByResource + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetHistoricalAvailabilityStatusesOfChildResource_GetChildHealthHistoryByResource() + { + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/stable/2022-10-01/examples/ChildAvailabilityStatuses_List.json + // this example is just showing the usage of "ChildAvailabilityStatuses_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); + + // invoke the operation and iterate over the result + string resourceUri = "subscriptions/227b734f-e14f-4de6-b7fc-3190c21e69f6/resourceGroups/JUHACKETRHCTEST/providers/Microsoft.Compute/virtualMachineScaleSets/rhctest/virtualMachines/4"; + ResourceIdentifier scope = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + await foreach (ResourceHealthAvailabilityStatus item in client.GetHistoricalAvailabilityStatusesOfChildResourceAsync(scope)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // GetCurrentChildHealthByResource + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAvailabilityStatusOfChildResources_GetCurrentChildHealthByResource() + { + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/stable/2022-10-01/examples/ChildResources_List.json + // this example is just showing the usage of "ChildResources_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); + + // invoke the operation and iterate over the result + string resourceUri = "resourceUri"; + ResourceIdentifier scope = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + await foreach (ResourceHealthAvailabilityStatus item in client.GetAvailabilityStatusOfChildResourcesAsync(scope)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/autorest.tests.md b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/autorest.tests.md index d52df1e761d4..4b84be903acf 100644 --- a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/autorest.tests.md +++ b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/autorest.tests.md @@ -10,11 +10,4 @@ require: ../src/autorest.md include-x-ms-examples-original-file: true testgen: sample: true - skipped-operations: - - Events_ListBySingleResource - - ChildResources_List - - AvailabilityStatuses_GetByResource - - AvailabilityStatuses_List - - ChildAvailabilityStatuses_GetByResource - - ChildAvailabilityStatuses_List ``` From 2aa003a7d442c3a027b9fd06aa08950fd3396b99 Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Fri, 21 Jul 2023 19:13:39 +0800 Subject: [PATCH 2/2] update according to Azure.Core.Expression.DataFactory beta4 --- ...ResourceManager.DataFactory.Samples.csproj | 7 +- .../Sample_DataFactoryDatasetCollection.cs | 98 ++++++++++ .../Sample_DataFactoryDatasetResource.cs | 91 +++++++++ ...mple_DataFactoryLinkedServiceCollection.cs | 84 ++++++++ ...Sample_DataFactoryLinkedServiceResource.cs | 77 ++++++++ ...toryManagedIdentityCredentialCollection.cs | 42 ++++ ...actoryManagedIdentityCredentialResource.cs | 38 ++++ .../Sample_DataFactoryPipelineCollection.cs | 180 ++++++++++++++++++ .../Sample_DataFactoryPipelineResource.cs | 171 +++++++++++++++++ .../Samples/Sample_DataFactoryResource.cs | 125 ++++++++++++ .../samples/autorest.tests.md | 7 - 11 files changed, 910 insertions(+), 10 deletions(-) diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Azure.ResourceManager.DataFactory.Samples.csproj b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Azure.ResourceManager.DataFactory.Samples.csproj index 3334980d88bf..1f205f1ede74 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Azure.ResourceManager.DataFactory.Samples.csproj +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Azure.ResourceManager.DataFactory.Samples.csproj @@ -1,8 +1,9 @@  - - - + + + + diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetCollection.cs index 328bc977d32c..ecf9011d9929 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetCollection.cs @@ -7,10 +7,13 @@ using System; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.Core.Expressions.DataFactory; using Azure.Identity; using Azure.ResourceManager; using Azure.ResourceManager.DataFactory; +using Azure.ResourceManager.DataFactory.Models; namespace Azure.ResourceManager.DataFactory.Samples { @@ -53,6 +56,101 @@ public async Task GetAll_DatasetsListByFactory() Console.WriteLine($"Succeeded"); } + // Datasets_Create + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_DatasetsCreate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_Create.json + // this example is just showing the usage of "Datasets_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 DataFactoryResource created on azure + // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); + DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); + + // get the collection of this DataFactoryDatasetResource + DataFactoryDatasetCollection collection = dataFactory.GetDataFactoryDatasets(); + + // invoke the operation + string datasetName = "exampleDataset"; + DataFactoryDatasetData data = new DataFactoryDatasetData(new AzureBlobDataset(new DataFactoryLinkedServiceReference("LinkedServiceReference", "exampleLinkedService")) + { + FolderPath = DataFactoryElement.FromExpression("@dataset().MyFolderPath"), + FileName = DataFactoryElement.FromExpression("@dataset().MyFileName"), + Format = new DatasetTextFormat(), + Parameters = +{ +["MyFileName"] = new EntityParameterSpecification(EntityParameterType.String), +["MyFolderPath"] = new EntityParameterSpecification(EntityParameterType.String), +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, datasetName, data); + DataFactoryDatasetResource 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 + DataFactoryDatasetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Datasets_Update + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_DatasetsUpdate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_Update.json + // this example is just showing the usage of "Datasets_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 DataFactoryResource created on azure + // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); + DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); + + // get the collection of this DataFactoryDatasetResource + DataFactoryDatasetCollection collection = dataFactory.GetDataFactoryDatasets(); + + // invoke the operation + string datasetName = "exampleDataset"; + DataFactoryDatasetData data = new DataFactoryDatasetData(new AzureBlobDataset(new DataFactoryLinkedServiceReference("LinkedServiceReference", "exampleLinkedService")) + { + FolderPath = DataFactoryElement.FromExpression("@dataset().MyFolderPath"), + FileName = DataFactoryElement.FromExpression("@dataset().MyFileName"), + Format = new DatasetTextFormat(), + Description = "Example description", + Parameters = +{ +["MyFileName"] = new EntityParameterSpecification(EntityParameterType.String), +["MyFolderPath"] = new EntityParameterSpecification(EntityParameterType.String), +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, datasetName, data); + DataFactoryDatasetResource 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 + DataFactoryDatasetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + // Datasets_Get [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetResource.cs index 622cd5935c1a..fbf0fea19b5a 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetResource.cs @@ -9,14 +9,105 @@ using System.Threading.Tasks; using Azure; using Azure.Core; +using Azure.Core.Expressions.DataFactory; using Azure.Identity; using Azure.ResourceManager; using Azure.ResourceManager.DataFactory; +using Azure.ResourceManager.DataFactory.Models; namespace Azure.ResourceManager.DataFactory.Samples { public partial class Sample_DataFactoryDatasetResource { + // Datasets_Create + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_DatasetsCreate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_Create.json + // this example is just showing the usage of "Datasets_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 DataFactoryDatasetResource created on azure + // for more information of creating DataFactoryDatasetResource, please refer to the document of DataFactoryDatasetResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + string datasetName = "exampleDataset"; + ResourceIdentifier dataFactoryDatasetResourceId = DataFactoryDatasetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName, datasetName); + DataFactoryDatasetResource dataFactoryDataset = client.GetDataFactoryDatasetResource(dataFactoryDatasetResourceId); + + // invoke the operation + DataFactoryDatasetData data = new DataFactoryDatasetData(new AzureBlobDataset(new DataFactoryLinkedServiceReference("LinkedServiceReference", "exampleLinkedService")) + { + FolderPath = DataFactoryElement.FromExpression("@dataset().MyFolderPath"), + FileName = DataFactoryElement.FromExpression("@dataset().MyFileName"), + Format = new DatasetTextFormat(), + Parameters = +{ +["MyFileName"] = new EntityParameterSpecification(EntityParameterType.String), +["MyFolderPath"] = new EntityParameterSpecification(EntityParameterType.String), +}, + }); + ArmOperation lro = await dataFactoryDataset.UpdateAsync(WaitUntil.Completed, data); + DataFactoryDatasetResource 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 + DataFactoryDatasetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Datasets_Update + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_DatasetsUpdate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_Update.json + // this example is just showing the usage of "Datasets_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 DataFactoryDatasetResource created on azure + // for more information of creating DataFactoryDatasetResource, please refer to the document of DataFactoryDatasetResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + string datasetName = "exampleDataset"; + ResourceIdentifier dataFactoryDatasetResourceId = DataFactoryDatasetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName, datasetName); + DataFactoryDatasetResource dataFactoryDataset = client.GetDataFactoryDatasetResource(dataFactoryDatasetResourceId); + + // invoke the operation + DataFactoryDatasetData data = new DataFactoryDatasetData(new AzureBlobDataset(new DataFactoryLinkedServiceReference("LinkedServiceReference", "exampleLinkedService")) + { + FolderPath = DataFactoryElement.FromExpression("@dataset().MyFolderPath"), + FileName = DataFactoryElement.FromExpression("@dataset().MyFileName"), + Format = new DatasetTextFormat(), + Description = "Example description", + Parameters = +{ +["MyFileName"] = new EntityParameterSpecification(EntityParameterType.String), +["MyFolderPath"] = new EntityParameterSpecification(EntityParameterType.String), +}, + }); + ArmOperation lro = await dataFactoryDataset.UpdateAsync(WaitUntil.Completed, data); + DataFactoryDatasetResource 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 + DataFactoryDatasetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + // Datasets_Get [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceCollection.cs index 14a687b439d6..9d45e54bb0a6 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceCollection.cs @@ -7,10 +7,13 @@ using System; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.Core.Expressions.DataFactory; using Azure.Identity; using Azure.ResourceManager; using Azure.ResourceManager.DataFactory; +using Azure.ResourceManager.DataFactory.Models; namespace Azure.ResourceManager.DataFactory.Samples { @@ -53,6 +56,87 @@ public async Task GetAll_LinkedServicesListByFactory() Console.WriteLine($"Succeeded"); } + // LinkedServices_Create + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_LinkedServicesCreate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Create.json + // this example is just showing the usage of "LinkedServices_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 DataFactoryResource created on azure + // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); + DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); + + // get the collection of this DataFactoryLinkedServiceResource + DataFactoryLinkedServiceCollection collection = dataFactory.GetDataFactoryLinkedServices(); + + // invoke the operation + string linkedServiceName = "exampleLinkedService"; + DataFactoryLinkedServiceData data = new DataFactoryLinkedServiceData(new AzureStorageLinkedService() + { + ConnectionString = DataFactoryElement.FromSecretString("DefaultEndpointsProtocol=https;AccountName=examplestorageaccount;AccountKey="), + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkedServiceName, data); + DataFactoryLinkedServiceResource 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 + DataFactoryLinkedServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // LinkedServices_Update + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_LinkedServicesUpdate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Update.json + // this example is just showing the usage of "LinkedServices_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 DataFactoryResource created on azure + // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); + DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); + + // get the collection of this DataFactoryLinkedServiceResource + DataFactoryLinkedServiceCollection collection = dataFactory.GetDataFactoryLinkedServices(); + + // invoke the operation + string linkedServiceName = "exampleLinkedService"; + DataFactoryLinkedServiceData data = new DataFactoryLinkedServiceData(new AzureStorageLinkedService() + { + ConnectionString = DataFactoryElement.FromSecretString("DefaultEndpointsProtocol=https;AccountName=examplestorageaccount;AccountKey="), + Description = "Example description", + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkedServiceName, data); + DataFactoryLinkedServiceResource 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 + DataFactoryLinkedServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + // LinkedServices_Get [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceResource.cs index 504f2d2f8f1f..50011d9e17ca 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceResource.cs @@ -9,14 +9,91 @@ using System.Threading.Tasks; using Azure; using Azure.Core; +using Azure.Core.Expressions.DataFactory; using Azure.Identity; using Azure.ResourceManager; using Azure.ResourceManager.DataFactory; +using Azure.ResourceManager.DataFactory.Models; namespace Azure.ResourceManager.DataFactory.Samples { public partial class Sample_DataFactoryLinkedServiceResource { + // LinkedServices_Create + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_LinkedServicesCreate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Create.json + // this example is just showing the usage of "LinkedServices_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 DataFactoryLinkedServiceResource created on azure + // for more information of creating DataFactoryLinkedServiceResource, please refer to the document of DataFactoryLinkedServiceResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + string linkedServiceName = "exampleLinkedService"; + ResourceIdentifier dataFactoryLinkedServiceResourceId = DataFactoryLinkedServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName, linkedServiceName); + DataFactoryLinkedServiceResource dataFactoryLinkedService = client.GetDataFactoryLinkedServiceResource(dataFactoryLinkedServiceResourceId); + + // invoke the operation + DataFactoryLinkedServiceData data = new DataFactoryLinkedServiceData(new AzureStorageLinkedService() + { + ConnectionString = DataFactoryElement.FromSecretString("DefaultEndpointsProtocol=https;AccountName=examplestorageaccount;AccountKey="), + }); + ArmOperation lro = await dataFactoryLinkedService.UpdateAsync(WaitUntil.Completed, data); + DataFactoryLinkedServiceResource 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 + DataFactoryLinkedServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // LinkedServices_Update + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_LinkedServicesUpdate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Update.json + // this example is just showing the usage of "LinkedServices_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 DataFactoryLinkedServiceResource created on azure + // for more information of creating DataFactoryLinkedServiceResource, please refer to the document of DataFactoryLinkedServiceResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + string linkedServiceName = "exampleLinkedService"; + ResourceIdentifier dataFactoryLinkedServiceResourceId = DataFactoryLinkedServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName, linkedServiceName); + DataFactoryLinkedServiceResource dataFactoryLinkedService = client.GetDataFactoryLinkedServiceResource(dataFactoryLinkedServiceResourceId); + + // invoke the operation + DataFactoryLinkedServiceData data = new DataFactoryLinkedServiceData(new AzureStorageLinkedService() + { + ConnectionString = DataFactoryElement.FromSecretString("DefaultEndpointsProtocol=https;AccountName=examplestorageaccount;AccountKey="), + Description = "Example description", + }); + ArmOperation lro = await dataFactoryLinkedService.UpdateAsync(WaitUntil.Completed, data); + DataFactoryLinkedServiceResource 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 + DataFactoryLinkedServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + // LinkedServices_Get [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedIdentityCredentialCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedIdentityCredentialCollection.cs index 06f8d93133e8..8cf731acea67 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedIdentityCredentialCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedIdentityCredentialCollection.cs @@ -7,10 +7,12 @@ using System; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Identity; using Azure.ResourceManager; using Azure.ResourceManager.DataFactory; +using Azure.ResourceManager.DataFactory.Models; namespace Azure.ResourceManager.DataFactory.Samples { @@ -53,6 +55,46 @@ public async Task GetAll_CredentialsListByFactory() Console.WriteLine($"Succeeded"); } + // Credentials_Create + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CredentialsCreate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_Create.json + // this example is just showing the usage of "CredentialOperations_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 DataFactoryResource created on azure + // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); + DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); + + // get the collection of this DataFactoryManagedIdentityCredentialResource + DataFactoryManagedIdentityCredentialCollection collection = dataFactory.GetDataFactoryManagedIdentityCredentials(); + + // invoke the operation + string credentialName = "exampleCredential"; + DataFactoryManagedIdentityCredentialData data = new DataFactoryManagedIdentityCredentialData(new DataFactoryManagedIdentityCredentialDefinition() + { + ResourceId = "/subscriptions/12345678-1234-1234-1234-12345678abc/resourcegroups/exampleResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleUami", + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, credentialName, data); + DataFactoryManagedIdentityCredentialResource 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 + DataFactoryManagedIdentityCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + // Credentials_Get [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedIdentityCredentialResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedIdentityCredentialResource.cs index 5926fa9a31a8..c0ce2cc59b3e 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedIdentityCredentialResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedIdentityCredentialResource.cs @@ -12,11 +12,49 @@ using Azure.Identity; using Azure.ResourceManager; using Azure.ResourceManager.DataFactory; +using Azure.ResourceManager.DataFactory.Models; namespace Azure.ResourceManager.DataFactory.Samples { public partial class Sample_DataFactoryManagedIdentityCredentialResource { + // Credentials_Create + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CredentialsCreate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_Create.json + // this example is just showing the usage of "CredentialOperations_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 DataFactoryManagedIdentityCredentialResource created on azure + // for more information of creating DataFactoryManagedIdentityCredentialResource, please refer to the document of DataFactoryManagedIdentityCredentialResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + string credentialName = "exampleCredential"; + ResourceIdentifier dataFactoryManagedIdentityCredentialResourceId = DataFactoryManagedIdentityCredentialResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName, credentialName); + DataFactoryManagedIdentityCredentialResource dataFactoryManagedIdentityCredential = client.GetDataFactoryManagedIdentityCredentialResource(dataFactoryManagedIdentityCredentialResourceId); + + // invoke the operation + DataFactoryManagedIdentityCredentialData data = new DataFactoryManagedIdentityCredentialData(new DataFactoryManagedIdentityCredentialDefinition() + { + ResourceId = "/subscriptions/12345678-1234-1234-1234-12345678abc/resourcegroups/exampleResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleUami", + }); + ArmOperation lro = await dataFactoryManagedIdentityCredential.UpdateAsync(WaitUntil.Completed, data); + DataFactoryManagedIdentityCredentialResource 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 + DataFactoryManagedIdentityCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + // Credentials_Get [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineCollection.cs index e558f3728ee1..0253aef3bd44 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineCollection.cs @@ -6,11 +6,14 @@ #nullable disable using System; +using System.Collections.Generic; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Identity; using Azure.ResourceManager; using Azure.ResourceManager.DataFactory; +using Azure.ResourceManager.DataFactory.Models; namespace Azure.ResourceManager.DataFactory.Samples { @@ -53,6 +56,183 @@ public async Task GetAll_PipelinesListByFactory() Console.WriteLine($"Succeeded"); } + // Pipelines_Create + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_PipelinesCreate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Pipelines_Create.json + // this example is just showing the usage of "Pipelines_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 DataFactoryResource created on azure + // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); + DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); + + // get the collection of this DataFactoryPipelineResource + DataFactoryPipelineCollection collection = dataFactory.GetDataFactoryPipelines(); + + // invoke the operation + string pipelineName = "examplePipeline"; + DataFactoryPipelineData data = new DataFactoryPipelineData() + { + Activities = +{ +new ForEachActivity("ExampleForeachActivity",new DataFactoryExpressionDefinition(DataFactoryExpressionType.Expression,"@pipeline().parameters.OutputBlobNameList"),new DataFactoryActivity[] +{ +new CopyActivity("ExampleCopyActivity",new DataFactoryBlobSource(),new DataFactoryBlobSink()) +{ +Inputs = +{ +new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +{ +Parameters = +{ +["MyFileName"] = BinaryData.FromString("examplecontainer.csv"), +["MyFolderPath"] = BinaryData.FromString("examplecontainer"), +}, +} +}, +Outputs = +{ +new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +{ +Parameters = +{ +["MyFileName"] = BinaryData.FromObjectAsJson(new Dictionary() +{ +["type"] = "Expression", +["value"] = "@item()"}), +["MyFolderPath"] = BinaryData.FromString("examplecontainer"), +}, +} +}, +DataIntegrationUnits = 32, +} +}) +{ +IsSequential = true, +} +}, + Parameters = +{ +["JobId"] = new EntityParameterSpecification(EntityParameterType.String), +["OutputBlobNameList"] = new EntityParameterSpecification(EntityParameterType.Array), +}, + Variables = +{ +["TestVariableArray"] = new PipelineVariableSpecification(PipelineVariableType.Array), +}, + RunDimensions = +{ +["JobId"] = BinaryData.FromObjectAsJson(new Dictionary() +{ +["type"] = "Expression", +["value"] = "@pipeline().parameters.JobId"}), +}, + ElapsedTimeMetricDuration = BinaryData.FromString("0.00:10:00"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, pipelineName, data); + DataFactoryPipelineResource 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 + DataFactoryPipelineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Pipelines_Update + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_PipelinesUpdate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Pipelines_Update.json + // this example is just showing the usage of "Pipelines_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 DataFactoryResource created on azure + // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); + DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); + + // get the collection of this DataFactoryPipelineResource + DataFactoryPipelineCollection collection = dataFactory.GetDataFactoryPipelines(); + + // invoke the operation + string pipelineName = "examplePipeline"; + DataFactoryPipelineData data = new DataFactoryPipelineData() + { + Description = "Example description", + Activities = +{ +new ForEachActivity("ExampleForeachActivity",new DataFactoryExpressionDefinition(DataFactoryExpressionType.Expression,"@pipeline().parameters.OutputBlobNameList"),new DataFactoryActivity[] +{ +new CopyActivity("ExampleCopyActivity",new DataFactoryBlobSource(),new DataFactoryBlobSink()) +{ +Inputs = +{ +new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +{ +Parameters = +{ +["MyFileName"] = BinaryData.FromString("examplecontainer.csv"), +["MyFolderPath"] = BinaryData.FromString("examplecontainer"), +}, +} +}, +Outputs = +{ +new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +{ +Parameters = +{ +["MyFileName"] = BinaryData.FromObjectAsJson(new Dictionary() +{ +["type"] = "Expression", +["value"] = "@item()"}), +["MyFolderPath"] = BinaryData.FromString("examplecontainer"), +}, +} +}, +DataIntegrationUnits = 32, +} +}) +{ +IsSequential = true, +} +}, + Parameters = +{ +["OutputBlobNameList"] = new EntityParameterSpecification(EntityParameterType.Array), +}, + ElapsedTimeMetricDuration = BinaryData.FromString("0.00:10:00"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, pipelineName, data); + DataFactoryPipelineResource 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 + DataFactoryPipelineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + // Pipelines_Get [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineResource.cs index eb5d5cbb7a63..51464076b998 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineResource.cs @@ -19,6 +19,177 @@ namespace Azure.ResourceManager.DataFactory.Samples { public partial class Sample_DataFactoryPipelineResource { + // Pipelines_Create + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_PipelinesCreate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Pipelines_Create.json + // this example is just showing the usage of "Pipelines_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 DataFactoryPipelineResource created on azure + // for more information of creating DataFactoryPipelineResource, please refer to the document of DataFactoryPipelineResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + string pipelineName = "examplePipeline"; + ResourceIdentifier dataFactoryPipelineResourceId = DataFactoryPipelineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName, pipelineName); + DataFactoryPipelineResource dataFactoryPipeline = client.GetDataFactoryPipelineResource(dataFactoryPipelineResourceId); + + // invoke the operation + DataFactoryPipelineData data = new DataFactoryPipelineData() + { + Activities = +{ +new ForEachActivity("ExampleForeachActivity",new DataFactoryExpressionDefinition(DataFactoryExpressionType.Expression,"@pipeline().parameters.OutputBlobNameList"),new DataFactoryActivity[] +{ +new CopyActivity("ExampleCopyActivity",new DataFactoryBlobSource(),new DataFactoryBlobSink()) +{ +Inputs = +{ +new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +{ +Parameters = +{ +["MyFileName"] = BinaryData.FromString("examplecontainer.csv"), +["MyFolderPath"] = BinaryData.FromString("examplecontainer"), +}, +} +}, +Outputs = +{ +new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +{ +Parameters = +{ +["MyFileName"] = BinaryData.FromObjectAsJson(new Dictionary() +{ +["type"] = "Expression", +["value"] = "@item()"}), +["MyFolderPath"] = BinaryData.FromString("examplecontainer"), +}, +} +}, +DataIntegrationUnits = 32, +} +}) +{ +IsSequential = true, +} +}, + Parameters = +{ +["JobId"] = new EntityParameterSpecification(EntityParameterType.String), +["OutputBlobNameList"] = new EntityParameterSpecification(EntityParameterType.Array), +}, + Variables = +{ +["TestVariableArray"] = new PipelineVariableSpecification(PipelineVariableType.Array), +}, + RunDimensions = +{ +["JobId"] = BinaryData.FromObjectAsJson(new Dictionary() +{ +["type"] = "Expression", +["value"] = "@pipeline().parameters.JobId"}), +}, + ElapsedTimeMetricDuration = BinaryData.FromString("0.00:10:00"), + }; + ArmOperation lro = await dataFactoryPipeline.UpdateAsync(WaitUntil.Completed, data); + DataFactoryPipelineResource 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 + DataFactoryPipelineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Pipelines_Update + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_PipelinesUpdate() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Pipelines_Update.json + // this example is just showing the usage of "Pipelines_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 DataFactoryPipelineResource created on azure + // for more information of creating DataFactoryPipelineResource, please refer to the document of DataFactoryPipelineResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + string pipelineName = "examplePipeline"; + ResourceIdentifier dataFactoryPipelineResourceId = DataFactoryPipelineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName, pipelineName); + DataFactoryPipelineResource dataFactoryPipeline = client.GetDataFactoryPipelineResource(dataFactoryPipelineResourceId); + + // invoke the operation + DataFactoryPipelineData data = new DataFactoryPipelineData() + { + Description = "Example description", + Activities = +{ +new ForEachActivity("ExampleForeachActivity",new DataFactoryExpressionDefinition(DataFactoryExpressionType.Expression,"@pipeline().parameters.OutputBlobNameList"),new DataFactoryActivity[] +{ +new CopyActivity("ExampleCopyActivity",new DataFactoryBlobSource(),new DataFactoryBlobSink()) +{ +Inputs = +{ +new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +{ +Parameters = +{ +["MyFileName"] = BinaryData.FromString("examplecontainer.csv"), +["MyFolderPath"] = BinaryData.FromString("examplecontainer"), +}, +} +}, +Outputs = +{ +new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +{ +Parameters = +{ +["MyFileName"] = BinaryData.FromObjectAsJson(new Dictionary() +{ +["type"] = "Expression", +["value"] = "@item()"}), +["MyFolderPath"] = BinaryData.FromString("examplecontainer"), +}, +} +}, +DataIntegrationUnits = 32, +} +}) +{ +IsSequential = true, +} +}, + Parameters = +{ +["OutputBlobNameList"] = new EntityParameterSpecification(EntityParameterType.Array), +}, + ElapsedTimeMetricDuration = BinaryData.FromString("0.00:10:00"), + }; + ArmOperation lro = await dataFactoryPipeline.UpdateAsync(WaitUntil.Completed, data); + DataFactoryPipelineResource 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 + DataFactoryPipelineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + // Pipelines_Get [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryResource.cs index b8b4b4300844..c3c7f3f711ca 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryResource.cs @@ -6,9 +6,11 @@ #nullable disable using System; +using System.Collections.Generic; using System.Threading.Tasks; using Azure; using Azure.Core; +using Azure.Core.Expressions.DataFactory; using Azure.Identity; using Azure.ResourceManager; using Azure.ResourceManager.DataFactory; @@ -607,6 +609,129 @@ public async Task GetDataFlowDebugSessions_DataFlowDebugSessionQueryByFactory() Console.WriteLine($"Succeeded"); } + // DataFlowDebugSession_AddDataFlow + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task AddDataFlowToDebugSession_DataFlowDebugSessionAddDataFlow() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlowDebugSession_AddDataFlow.json + // this example is just showing the usage of "DataFlowDebugSession_AddDataFlow" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DataFactoryResource created on azure + // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); + DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); + + // invoke the operation + DataFactoryDataFlowDebugPackageContent content = new DataFactoryDataFlowDebugPackageContent() + { + SessionId = Guid.Parse("f06ed247-9d07-49b2-b05e-2cb4a2fc871e"), + DataFlow = new DataFactoryDataFlowDebugInfo(new DataFactoryMappingDataFlowDefinition() + { + Sources = +{ +new DataFlowSource("source1") +{ +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"DelimitedText2"), +} +}, + Sinks = +{ +}, + Transformations = +{ +}, + Script = "\n\nsource(output(\n\t\tColumn_1 as string\n\t),\n\tallowSchemaDrift: true,\n\tvalidateSchema: false) ~> source1", + }) + { + Name = "dataflow1", + }, + Datasets = +{ +new DataFactoryDatasetDebugInfo(new DelimitedTextDataset(new DataFactoryLinkedServiceReference("LinkedServiceReference","linkedService5")) +{ +DataLocation = new AzureBlobStorageLocation() +{ +Container = "dataflow-sample-data", +FileName = "Ansiencoding.csv", +}, +ColumnDelimiter = ",", +QuoteChar = "\"", +EscapeChar = "\\", +FirstRowAsHeader = true, +Schema = new DatasetSchemaDataElement[] +{ +new DatasetSchemaDataElement() +{ +SchemaColumnType = "String", +} +}, +Annotations = +{ +}, +}) +{ +Name = "dataset1", +} +}, + LinkedServices = +{ +new DataFactoryLinkedServiceDebugInfo(new AzureBlobStorageLinkedService() +{ +ConnectionString = "DefaultEndpointsProtocol=https;AccountName=;EndpointSuffix=core.windows.net;", +EncryptedCredential = BinaryData.FromString(""), +Annotations = +{ +}, +}) +{ +Name = "linkedService1", +} +}, + DebugSettings = new DataFlowDebugPackageDebugSettings() + { + SourceSettings = +{ +new DataFlowSourceSetting() +{ +SourceName = "source1", +RowLimit = 1000, +},new DataFlowSourceSetting() +{ +SourceName = "source2", +RowLimit = 222, +} +}, + Parameters = +{ +["sourcePath"] = BinaryData.FromString("Toy"), +}, + DatasetParameters = BinaryData.FromObjectAsJson(new Dictionary() + { + ["Movies"] = new Dictionary() + { + ["path"] = "abc" + }, + ["Output"] = new Dictionary() + { + ["time"] = "def" + } + }), + }, + }; + DataFactoryDataFlowStartDebugSessionResult result = await dataFactory.AddDataFlowToDebugSessionAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + // DataFlowDebugSession_Delete [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/autorest.tests.md b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/autorest.tests.md index 249f7b27d258..f26fdc2eb48f 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/autorest.tests.md +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/autorest.tests.md @@ -10,11 +10,4 @@ require: ../src/autorest.md include-x-ms-examples-original-file: true testgen: sample: true - skipped-operations: - - DataFlowDebugSession_AddDataFlow - - Datasets_CreateOrUpdate - - LinkedServices_CreateOrUpdate - - Pipelines_CreateOrUpdate - - CredentialOperations_CreateOrUpdate - - DataFlowDebugSession_AddDataFlow ```