我使用的是数据工厂,我有一个活动将数据从一个位置复制到另一个位置。但是,我希望目的地位置像"container/Year/Month/Day",自动生成年、月和日。源地址和目标地址作为参数提供给我的作业,因此它们应该在活动的参数部分。我被卡住了,不知道如何指定它们
如果您使用的是直接复制活动,那么您可以用与输入文件相同的方式指定Blob文件夹路径:
{
"name": "AzureBlobOutput",
"properties": {
"type": "AzureBlob",
"linkedServiceName": "StorageLinkedService",
"typeProperties": {
"folderPath": "mycontainer/myfolder/yearno={Year}/monthno={Month}/dayno={Day}/hourno={Hour}/",
"partitionedBy": [
{
"name": "Year",
"value": {
"type": "DateTime",
"date": "SliceStart",
"format": "yyyy"
}
},
{
"name": "Month",
"value": {
"type": "DateTime",
"date": "SliceStart",
"format": "%M"
}
},
{
"name": "Day",
"value": {
"type": "DateTime",
"date": "SliceStart",
"format": "%d"
}
},
{
"name": "Hour",
"value": {
"type": "DateTime",
"date": "SliceStart",
"format": "%H"
}
}
],
"format": {
"type": "TextFormat",
"columnDelimiter": "t",
"rowDelimiter": "n"
}
},
"availability": {
"frequency": "Hour",
"interval": 1
}
}
}
取自此处的示例文档https://azure.microsoft.com/en-us/documentation/articles/data-factory-azure-blob-connector/
如果您正在使用自定义.NET活动,则需要将参数作为typeProperties JSON部分中extendedProperties的一部分进行传递:
"typeProperties": {
"AssemblyName": "MyDotNetActivity.dll",
"EntryPoint": "MyDotNetActivityNS.MyDotNetActivity",
"PackageLinkedService": "StorageLinkedService",
"PackageFile": "customactivitycontainer/MyDotNetActivity.zip",
"extendedProperties": {
"SliceStart": "$$Text.Format('{0:yyyyMMddHH-mm}', Time.AddMinutes(SliceStart, 0))"
}
},
然后读取C#类中的extendedProperties元数据,如下所示:
public IDictionary<string, string> Execute(
IEnumerable<LinkedService> linkedServices,
IEnumerable<Dataset> datasets,
Activity activity,
IActivityLogger logger)
{
// to get extended properties (for example: SliceStart)
DotNetActivity dotNetActivity = (DotNetActivity)activity.TypeProperties;
string sliceStartString = dotNetActivity.ExtendedProperties["SliceStart"];
// to log all extended properties
IDictionary<string, string> extendedProperties = dotNetActivity.ExtendedProperties;
logger.Write("Logging extended properties if any...");
foreach (KeyValuePair<string, string> entry in extendedProperties)
{
logger.Write("<key:{0}> <value:{1}>", entry.Key, entry.Value);
}
....
取自此处的示例文档https://azure.microsoft.com/en-gb/documentation/articles/data-factory-use-custom-activities/