在azure数据工厂中动态选择存储表

时间:2015-09-29 14:35:21

标签: azure apache-pig azure-storage hdinsight azure-data-factory

我有一套现有的azure存储表,每个客户端一个,用于在多租户云系统中保存事件。

例如,可能有3个表来保存登录信息:

ClientASignins ClientBSignins ClientCSignins

有没有办法在复制操作或Pig脚本之类的东西中动态循环这些?

或者有另一种方法可以达到这个结果吗?

非常感谢!

2 个答案:

答案 0 :(得分:0)

如果您在其他位置(如Azure存储)中跟踪这些表,则可以使用PowerShell遍历每个表并在每个表上创建一个配置单元表。例如:

foreach($t in $tableList) {
    $hiveQuery = "CREATE EXTERNAL TABLE $t(IntValue int)
 STORED BY 'com.microsoft.hadoop.azure.hive.AzureTableHiveStorageHandler'
 TBLPROPERTIES(
  ""azure.table.name""=""$($t.tableName)"",
  ""azure.table.account.uri""=""http://$storageAccount.table.core.windows.net"",
  ""azure.table.storage.key""=""$((Get-AzureStorageKey $storageAccount).Primary)"");"
Out-File -FilePath .\HiveCreateTable.q -InputObject $hiveQuery -Encoding ascii
$hiveQueryBlob = Set-AzureStorageBlobContent -File .\HiveCreateTable.q -Blob "queries/HiveCreateTable.q" `
  -Container $clusterContainer.Name -Force
$createTableJobDefinition = New-AzureHDInsightHiveJobDefinition -QueryFile /queries/HiveCreateTable.q
$job = Start-AzureHDInsightJob -JobDefinition $createTableJobDefinition -Cluster $cluster.Name
Wait-AzureHDInsightJob -Job $job
#INSERT YOUR OPERATIONS FOR EACH TABLE HERE
}

研究: http://blogs.msdn.com/b/mostlytrue/archive/2014/04/04/analyzing-azure-table-storage-data-with-hdinsight.aspx

How can manage Azure Table with Powershell?

答案 1 :(得分:0)

最后,我选择了一些用c#编写的Azure数据工厂自定义活动,现在我的工作流程是:

  1. 自定义活动:将当前切片的数据聚合到单个blob文件中,以便在Pig中进行分析。
  2. HDInsight:用猪分析
  3. 自定义活动:将数据分散到目标表阵列,从blob存储到表存储。
  4. 我这样做是为了使管道尽可能简单,并且不需要任何重复的管道/脚本。

    参考文献:

    Use Custom Activities In Azure Data Factory pipeline

    HttpDataDownloader Sample