/// <summary>
 /// Create a new Dataset instance or update an existing instance.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.DataFactories.IDatasetOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The resource group name of the data factory.
 /// </param>
 /// <param name='dataFactoryName'>
 /// Required. A unique data factory instance name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The parameters required to create or update a Dataset.
 /// </param>
 /// <returns>
 /// The CreateOrUpdate Dataset operation response.
 /// </returns>
 public static Task<DatasetCreateOrUpdateResponse> BeginCreateOrUpdateAsync(
     this IDatasetOperations operations,
     string resourceGroupName,
     string dataFactoryName,
     DatasetCreateOrUpdateParameters parameters)
 {
     return operations.BeginCreateOrUpdateAsync(
         resourceGroupName,
         dataFactoryName,
         parameters,
         CancellationToken.None);
 }
 /// <summary>
 /// Create a new Dataset instance or update an existing instance.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.DataFactories.IDatasetOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The resource group name of the data factory.
 /// </param>
 /// <param name='dataFactoryName'>
 /// Required. A unique data factory instance name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The parameters required to create or update a Dataset.
 /// </param>
 /// <returns>
 /// The CreateOrUpdate Dataset operation response.
 /// </returns>
 public static DatasetCreateOrUpdateResponse BeginCreateOrUpdate(
     this IDatasetOperations operations,
     string resourceGroupName,
     string dataFactoryName,
     DatasetCreateOrUpdateParameters parameters)
 {
     return Task.Factory.StartNew(
             s => ((IDatasetOperations)s).BeginCreateOrUpdateAsync(resourceGroupName, dataFactoryName, parameters),
             operations,
             CancellationToken.None,
             TaskCreationOptions.None,
             TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
        private void CreateDataSet_MahoutInputProductsUsage(DataFactoryManagementClient client)
        {
            // Setup DataSet Parameters
            var parameters = new DatasetCreateOrUpdateParameters()
            {
                Dataset =
                    new Dataset("MahoutInputProductsUsageTable", new DatasetProperties()
                    {
                        Structure = new List<DataElement>()
                        {
                            new DataElement()
                            {
                                Name = "UserId",
                                Type = "String"
                            },
                            new DataElement()
                            {
                                Name = "ProductId",
                                Type = "String"
                            },
                        },
                        LinkedServiceName = "StorageLinkedService",
                        TypeProperties = new AzureBlobDataset()
                        {
                            FolderPath = "productrec/mahoutinput/yearno={Year}/monthno={Month}/",
                            PartitionedBy = new List<Partition>()
                            {
                                new Partition() { Name = "Year", Value = new DateTimePartitionValue() { Date = "SliceStart", Format = "yyyy" }},
                                new Partition() { Name = "Month", Value = new DateTimePartitionValue() { Date = "SliceStart", Format = "%M" }}
                            }
                        },
                        Availability = new Availability()
                        {
                            Frequency = "month",
                            Interval = 1
                        },
                        
                    })
            };

            // Create DataSet
            client.Datasets.CreateOrUpdateAsync(Parameters.Tenant.SiteName, Parameters.Tenant.SiteName, parameters).Wait();
        }
        private void CreateDataSet_ProductsRecommendationOutput(DataFactoryManagementClient client)
        {
            // Setup DataSet Parameters
            var parameters = new DatasetCreateOrUpdateParameters()
            {
                Dataset =
                    new Dataset("ProductsRecommendationOutputTable", new DatasetProperties()
                    {
                        Structure = new List<DataElement>()
                        {
                            new DataElement()
                            {
                                Name = "CustomerId",
                                Type = "Int"
                            },
                            new DataElement()
                            {
                                Name = "RecommendedProductId",
                                Type = "Int"
                            },
                        },
                        LinkedServiceName = "StorageLinkedService",
                        TypeProperties = new AzureBlobDataset()
                        {
                            FolderPath = "productrec/recommendationsoutput/yearno={Year}/monthno={Month}/",
                            PartitionedBy = new List<Partition>()
                            {
                                new Partition() { Name = "Year", Value = new DateTimePartitionValue() { Date = "SliceStart", Format = "yyyy" }},
                                new Partition() { Name = "Month", Value = new DateTimePartitionValue() { Date = "SliceStart", Format = "%M" }}
                            },
                            Format = new TextFormat()
                            {
                                ColumnDelimiter = "\t"
                            }
                        },
                        Availability = new Availability()
                        {
                            Frequency = "month",
                            Interval = 1
                        }
                    })
            };

            // Create DataSet
            client.Datasets.CreateOrUpdateAsync(Parameters.Tenant.SiteName, Parameters.Tenant.SiteName, parameters).Wait();
        }
        private void CreateDataSet_ProductsRecommendationSql(DataFactoryManagementClient client)
        {
            // Setup DataSet Parameters
            var parameters = new DatasetCreateOrUpdateParameters()
            {
                Dataset =
                    new Dataset("ProductsRecommendationSQLTable", new DatasetProperties()
                    {
                        Structure = new List<DataElement>()
                        {
                            new DataElement()
                            {
                                Name = "CustomerId",
                                Type = "Int"
                            },
                            new DataElement()
                            {
                                Name = "RecommendedProductId",
                                Type = "Int"
                            },
                        },
                        LinkedServiceName = "AzureSqlLinkedService",
                        TypeProperties = new AzureSqlTableDataset()
                        {
                            TableName = "PersonalizedRecommendations"
                        },
                        Availability = new Availability()
                        {
                            Frequency = "month",
                            Interval = 1
                        }
                    })
            };

            // Create DataSet
            client.Datasets.CreateOrUpdateAsync(Parameters.Tenant.SiteName, Parameters.Tenant.SiteName, parameters).Wait();
        }
        private void CreateDataSet_RawProductsUsage(DataFactoryManagementClient client)
        {
            // Setup DataSet Parameters
            var parameters = new DatasetCreateOrUpdateParameters()
            {
                Dataset =
                    new Dataset("RawProductsUsageTable", new DatasetProperties()
                    {
                        Structure = new List<DataElement>()
                        {
                            new DataElement()
                            {
                                Name = "UserId",
                                Type = "String"
                            },
                            new DataElement()
                            {
                                Name = "ProductId",
                                Type = "String"
                            },
                            new DataElement()
                            {
                                Name = "Rating",
                                Type = "Int"
                            },
                            new DataElement()
                            {
                                Name = "Timestamp",
                                Type = "String"
                            },
                        },
                        LinkedServiceName = "StorageLinkedService",
                        TypeProperties = new AzureBlobDataset()
                        {
                            FolderPath = "productrec/rawusageevents/",
                            Format = new TextFormat()
                            {
                                ColumnDelimiter = "\t"
                            },
                        },
                        Availability = new Availability()
                        {
                            Frequency = "month",
                            Interval = 24,
                            Style = "StartOfInterval"
                        }
                    })
            };

            // Create DataSet
            client.Datasets.CreateOrUpdateAsync(Parameters.Tenant.SiteName, Parameters.Tenant.SiteName, parameters).Wait();
        }