无法从 ADF 执行 U-SQL 脚本:ScriptPath 不应为空

Cannot execute U-SQL script from ADF: ScriptPath should not be null

我们正在尝试从 ADFv2 运行 一个 U-SQL 脚本,但是有一个错误阻止了执行。考虑到有关此问题的 MS 文档没有帮助,我再次在 SO 中请求帮助解决此问题。

  1. 最初的问题是如何将U-SQL脚本部署到ADLA。我们找不到任何有用的东西,最后只是将脚本以 2 种格式复制粘贴到 ADLA 和 Azure Blob 存储上:.usql 和 .txt。 (这也可能是问题之一)。

  2. 我们根据 MS documentation 创建了 ARM,但它失败并出现错误:ScriptPath should not be null 这很奇怪,因为这个值已经在链接服务上指定,并且也在 activity.

下面是我们创建的LS和activity:

链接服务:

{
    "type": "linkedservices",
    "name": "LinkedServiceofAzureBlobStorageforscriptPath",
    "dependsOn": ["[parameters('dataFactoryName')]"],
    "apiVersion": "[variables('apiVersion')]",
    "properties": {
        "type": "AzureStorage",
        "typeProperties": {
            "connectionString": {
                "type": "SecureString",
                "value": "DefaultEndpointsProtocol=https;AccountName=<account>;AccountKey=<key>;EndpointSuffix=core.windows.net"
            }
            "scriptPath": "container\script.txt"
            //"scriptPath": "https://storage.blob.core.windows.net/container/script.txt"//"wasb://container@storage/script.txt",
        }
    }
}

Activity:

{
            "type": "DataLakeAnalyticsU-SQL",
            "typeProperties": {
                //"script": "master.dbo.sp_test()",
                "scriptPath": "container\script.txt"//"scriptPath": "https://storage.blob.core.windows.net/container/script.txt"//"wasb://container@storage/script.txt",
                "scriptLinkedService": {
                    "referenceName": "LinkedServiceofAzureBlobStorageforscriptPath",
                    "type": "LinkedServiceReference"
                },
                "degreeOfParallelism": 3,
                "priority": 100
            },
            "name": "CopyFromAzureBlobToAzureSQL",
            "description": "Copy data frm Azure blob to Azure SQL",
            "linkedServiceName": {
                "referenceName": "AzureDataLakeAnalyticsLinkedService",
                "type": "LinkedServiceReference"
            }
        }

也尝试了 但仍然没有成功。

这是我们正在测试的虚拟脚本:

@a =
    SELECT *
    FROM(
        VALUES
        (
            "Contoso",
            1500.0
        ),
        (
            "Woodgrove",
            2700.0
        ),
        (
            "Contoso",
            1500.0
        ),
        (
            "Woodgrove",
            2700.0
        ),
        (
            "Contoso",
            1500.0
        ),
        (
            "Woodgrove",
            2700.0
        ),
        (
            "Contoso",
            1500.0
        ),
        (
            "Woodgrove",
            2700.0
        ),
        (
            "Contoso",
            1500.0
        ),
        (
            "Woodgrove",
            2700.0
        ),
        (
            "Contoso",
            1500.0
        ),
        (
            "Woodgrove",
            2700.0
        )
        ) AS 
              D( customer, amount );
OUTPUT @a
TO "/data"+DateTime.Now.ToString("yyyyMMddHHmmss")+".csv"
USING Outputters.Csv();

但如果您能指出一些更复杂的示例,并在脚本中隐藏一些代码,那就太好了。

谢谢!

更新 26.01.2018

在就 usql 的部署咨询了 MS 之后,我们得到了 powershell 命令的组合:

您不需要链接服务中的脚本路径。

blob 链接服务应该是:

{
    "name": "Blob Name",
    "properties": {
        "type": "AzureStorage",
        "typeProperties": {
            "connectionString": {
                "type": "SecureString",
                "value": "DefaultEndpointsProtocol=https;AccountName=etc"
            }
        },
        "connectVia": {
            "referenceName": "Your IR Ref",
            "type": "IntegrationRuntimeReference"
        }
    }
}

然后在 activity 中使用容器和文件名引用脚本,如下所示,以及链接服务的引用名称。

    "activities": [
        {
            "name": "U-SQL1",
            "type": "DataLakeAnalyticsU-SQL",
            "policy": {
                "timeout": "7.00:00:00",
                "retry": 0,
                "retryIntervalInSeconds": 20
            },
            "typeProperties": {
                "scriptPath": "u-sql1/Test",
                "degreeOfParallelism": {
                    "value": "5",
                    "type": "Expression"
                },
                "priority": 1,
                "compilationMode": "Full",
                "scriptLinkedService": {
                    "referenceName": "Your Blob Ref",
                    "type": "LinkedServiceReference"
                }
            },
            "linkedServiceName": {
                "referenceName": "Your ADLa Ref",
                "type": "LinkedServiceReference"
            }
        },

有关信息,我忽略了 MS 文档并使用新的开发 UI 创建了这个 JSON,因为我有私人预览权限。以上已经过测试并且可以正常工作,因为我在此处的 blob post 中使用它:

https://mrpaulandrew.com/2017/12/20/controlling-u-sql-job-aus-with-azure-data-factory-v2-pipeline-parameters/

希望这对您有所帮助。