【问题标题】:Azure Data Factory get blob path with sas token in custom activityAzure 数据工厂在自定义活动中获取带有 sas 令牌的 blob 路径
【发布时间】:2018-06-18 06:16:44
【问题描述】:

我正在尝试在 Azure 数据工厂中构建一个自定义活动,该活动将 blob 作为输入数据集,并希望将此 blob 的 sas 令牌路径传递给需要此类路径的 API。

有没有办法在自定义活动中使用 sas 令牌获取 blob 的路径?

【问题讨论】:

    标签: azure-storage azure-data-factory custom-activity


    【解决方案1】:

    我想出了一个办法。 ADF v1 中的部分自定义活动是具有上下文参数的 Execute 方法。从该上下文中,您可以获取到 blob 存储的连接字符串和 blob 的路径,然后您可以像这样提取 sas 令牌:

    public override IDictionary<string, string> Execute(
    AOMDotNetActivityContext context,
    IActivityLogger logger)
    {
        string blobConnectionString = context.ConnectionString;
        CloudStorageAccount inputStorageAccount = CloudStorageAccount.Parse(blobConnectionString);
        var blob = new CloudBlob(new Uri(inputStorageAccount.BlobEndpoint, Path.Combine(context.FolderPath, context.FileName)), inputStorageAccount.Credentials);
        SharedAccessBlobPolicy adHocSAS = new SharedAccessBlobPolicy()
        {
            SharedAccessExpiryTime = DateTime.UtcNow.AddHours(48),
            Permissions = SharedAccessBlobPermissions.Read | SharedAccessBlobPermissions.Delete
        };
        string sasBlobToken = blob.GetSharedAccessSignature(adHocSAS);
        string fullUri = new Uri(blob.Uri, sasBlobToken).ToString();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-04
      • 2020-05-30
      • 2018-08-02
      • 1970-01-01
      • 1970-01-01
      • 2018-05-12
      • 2018-10-02
      相关资源
      最近更新 更多