简体   繁体   中英

Error calling the azure function from data factory pipeline trigger

I am calling an http triggered Azure function app in data factory pipeline using ADF function activity. It is executing successfully in debug mode, but when I publish that pipeline and run the same code using data factory triggers I get below error-

{
    "errorCode": "3600",
    "message": "Object reference not set to an instance of an object.",
    "failureType": "UserError",
    "target": "AzureFunction"
}

Please let me know if I need to make some additional properties changes or I am missing anything here. Also is there any way I can see what URL is getting generated when I call function app through function activity in ADF.

I have tried calling same function app using web activity in ADF and that is working fine in both debug and trigger mode.

Linked service code for Azure function

{
    "name": "linkedservicesAzureFunctions",
    "type": "Microsoft.DataFactory/factories/linkedservices",
    "properties": {
        "typeProperties": {
            "functionAppUrl": "https://xyz.azurewebsites.net",
            "functionKey": {
                "type": "AzureKeyVaultSecret",
                "store": {
                    "type": "LinkedServiceReference",
                    "referenceName": "linkedservicesKeyVault"
                },
                "secretName": "functions-host-key-default"
            }
        },
        "type": "AzureFunction"
    }
}

There is a known Bug in Azure Data Factory and they are working on that. For now if you are creating the Azure Data Factory using .NET SDK then you'll need to set Headers like this in Azure Function Activity.

new AzureFunctionActivity
                {
                    Name = "CopyFromBlobToSnowFlake",
                    LinkedServiceName = new LinkedServiceReference(pipelineStructure.AzureFunctionLinkedService),
                    Method = "POST",
                    Body = body,
                    FunctionName = "LoadBlobsIntoSnowFlake",
                    Headers = new Dictionary<string, string>{ },
                    DependsOn = new List<ActivityDependency>
                    {
                        new ActivityDependency{
                            Activity = "CopyFromOPSqlServerToBlob",
                            DependencyConditions= new List<string>{"Succeeded" }
                        }
                    }
                }

If you are creating Azure Function Activity through UI then just update the description of Activity then Publish and Headers will automatically get Initialized.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM