gpt4 book ai didi

azure - 尝试在 Azure 数据工厂 v1 中使用 .Net 监视数据切片时,数据切片计数为零

转载 作者:行者123 更新时间:2023-12-03 04:22:54 25 4
gpt4 key购买 nike

我想使用 .NET API 监视现有的 Azure 数据工厂管道。我一直在引用Microsoft provided .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: \t\t{0}", run.Status);
Console.WriteLine("DataSliceStart: \t{0}", run.DataSliceStart);
Console.WriteLine("DataSliceEnd: \t\t{0}", run.DataSliceEnd);
Console.WriteLine("ActivityId: \t\t{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(
资源组名称,
数据工厂名称,
数据集_目标,
新的 DataSliceRunListParameters()
{
DataSliceStartTime = PipelineActivePeriodStartTime.ConvertToISO8601DateTimeString()
});

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

  • 另一个问题是,我想获取 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: \t\t{0}", run.Status);
    Console.WriteLine("DataSliceStart: \t{0}", run.DataSliceStart);
    Console.WriteLine("DataSliceEnd: \t\t{0}", run.DataSliceEnd);
    Console.WriteLine("ActivityId: \t\t{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.
    }

    关于azure - 尝试在 Azure 数据工厂 v1 中使用 .Net 监视数据切片时,数据切片计数为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46998502/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com