在Azure data Factory v1中尝试使用.Net监视数据切片时,在数据切片中获取零计数



我想使用.NET API监控现有的Azure数据工厂管道。我一直在参考微软提供的.NET API。

这是代码:

using System.Configuration;
using System.Collections.ObjectModel;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure;
using Microsoft.Azure.Management.DataFactories;
using Microsoft.Azure.Management.DataFactories.Models;
using Microsoft.Azure.Management.DataFactories.Common.Models;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System;
namespace ADFv1Tutorial
{
class Program
{
static void Main(string[] args)
{
// create data factory management client
//IMPORTANT: specify the name of Azure resource group here
string resourceGroupName = "<my_resourcegroup_name>";
//IMPORTANT: the name of the data factory must be globally unique.
// Therefore, update this value. For example:APITutorialFactory05122017
string dataFactoryName = "<my data_factory name>";
DateTime PipelineActivePeriodStartTime = new DateTime(2017, 8, 9, 0, 0, 0, 0, DateTimeKind.Utc);
DateTime PipelineActivePeriodEndTime = PipelineActivePeriodStartTime.AddYears(10);// AddMinutes(60);
string Dataset_Destination = "<my dataset_name>";
TokenCloudCredentials aadTokenCredentials = new TokenCloudCredentials(
ConfigurationManager.AppSettings["SubscriptionId"],
GetAuthorizationHeader().Result);
Uri resourceManagerUri = new Uri(ConfigurationManager.AppSettings["ResourceManagerEndpoint"]);
DataFactoryManagementClient client = new DataFactoryManagementClient(aadTokenCredentials, resourceManagerUri); 
Console.WriteLine("Getting run details of a data slice");
// give it a few minutes for the output slice to be ready
Console.WriteLine("nGive it a few minutes for the output slice to be ready and press any key.");
//Console.ReadKey();
var datasliceRunListResponse = client.DataSliceRuns.List(
resourceGroupName,
dataFactoryName,
Dataset_Destination,
new DataSliceRunListParameters()
{
DataSliceStartTime = PipelineActivePeriodStartTime.ConvertToISO8601DateTimeString()
});
foreach (DataSliceRun run in datasliceRunListResponse.DataSliceRuns)
{
Console.WriteLine("Status: tt{0}", run.Status);
Console.WriteLine("DataSliceStart: t{0}", run.DataSliceStart);
Console.WriteLine("DataSliceEnd: tt{0}", run.DataSliceEnd);
Console.WriteLine("ActivityId: tt{0}", run.ActivityName);
Console.WriteLine("ProcessingStartTime: t{0}", run.ProcessingStartTime);
Console.WriteLine("ProcessingEndTime: t{0}", run.ProcessingEndTime);
Console.WriteLine("ErrorMessage: t{0}", run.ErrorMessage);
//var r = run.Properties.Values;
//run.
//run.
}

Console.WriteLine("nPress any key to exit.");
Console.ReadKey();
}
public static async Task<string> GetAuthorizationHeader()
{
AuthenticationContext context = new AuthenticationContext(ConfigurationManager.AppSettings["ActiveDirectoryEndpoint"] + ConfigurationManager.AppSettings["ActiveDirectoryTenantId"]);
ClientCredential credential = new ClientCredential(
ConfigurationManager.AppSettings["ApplicationId"],
ConfigurationManager.AppSettings["Password"]);
AuthenticationResult result = await context.AcquireTokenAsync(
resource: ConfigurationManager.AppSettings["WindowsManagementUri"],
clientCredential: credential);
if (result != null)
return result.AccessToken;
throw new InvalidOperationException("Failed to acquire token");
}
}

}

我在App.Config文件中使用了正确的tenantid、applicationid、applicationkey和subscriptionid。

我面临几个问题:

  1. 在代码部分:

var datasliceRunListResponse = client.DataSliceRuns.List( resourceGroupName, dataFactoryName, Dataset_Destination, new DataSliceRunListParameters() { DataSliceStartTime = PipelineActivePeriodStartTime.ConvertToISO8601DateTimeString() });

如果我使用datasliceRunListResponse.dataslices.count那么我得到0作为数据切片计数。为什么

  1. 另一个问题是,我想获得ADF拉取和推送的数据大小。如何获取该信息

请帮忙。

我以前和现在都尝试过这段代码,现在我可以得到计数了。只需检查开始时间和数据集名称。并且只在切片附加到输出数据集时才提到它

string dataFactoryName = "DataFactoryName";
DateTime PipelineActivePeriodStartTime = new DateTime(2017, 8, 29, 0, 0, 0, 0, DateTimeKind.Utc);
DateTime PipelineActivePeriodEndTime = DateTime(2017, 10, 13, 0, 0, 0, 0, DateTimeKind.Utc);
string Dataset_Destination = "Output Dataset Name";

Console.WriteLine("Getting run details of a data slice");
Console.WriteLine("nGive it a few minutes for the output slice to be ready and press any key.");
//Console.ReadKey();
var datasliceRunListResponse = client.DataSliceRuns.List(
resourceGroupName,
dataFactoryName,
Dataset_Destination,
new DataSliceRunListParameters()
{
DataSliceStartTime = PipelineActivePeriodStartTime.ConvertToISO8601DateTimeString()
});
Console.WriteLine("count is {0}", datasliceRunListResponse.DataSliceRuns.Count()); Console.ReadKey();
foreach (DataSliceRun run in datasliceRunListResponse.DataSliceRuns)
{
Console.WriteLine("Status: tt{0}", run.Status);
Console.WriteLine("DataSliceStart: t{0}", run.DataSliceStart);
Console.WriteLine("DataSliceEnd: tt{0}", run.DataSliceEnd);
Console.WriteLine("ActivityId: tt{0}", run.ActivityName);
Console.WriteLine("ProcessingStartTime: t{0}", run.ProcessingStartTime);
Console.WriteLine("ProcessingEndTime: t{0}", run.ProcessingEndTime);
Console.WriteLine("ErrorMessage: t{0}", run.ErrorMessage);
//var r = run.Properties.Values;
//run.
//run.
}

相关内容

  • 没有找到相关文章

最新更新