Atividade de função do Azure no Azure Data FactoryAzure Function activity in Azure Data Factory
Azure Data Factory
Azure Synapse Analytics
Saiba como usar a atividade do Azure Functions para executar uma função do Azure em um pipeline do Data Factory.The Azure Function activity allows you to run Azure Functions in a Data Factory pipeline. Para executar uma função do Azure, você precisará criar uma conexão de serviço vinculado e uma atividade que especifica a função do Azure que você planeja executar.To run an Azure Function, you need to create a linked service connection and an activity that specifies the Azure Function that you plan to execute.
Para ver uma introdução de oito minutos e uma demonstração desse recurso, assista ao seguinte vídeo:For an eight-minute introduction and demonstration of this feature, watch the following video:
Serviço de função vinculado do AzureAzure Function linked service
O tipo de retorno da função do Azure deve ser um JObject
válido.The return type of the Azure function has to be a valid JObject
. (Lembre-se de que JArraynão é um JObject
.) Qualquer tipo de retorno diferente de JObject
falha e gera o erro do usuário O conteúdo da resposta não é um JObject válido.(Keep in mind that JArray is not a JObject
.) Any return type other than JObject
fails and raises the user error Response Content is not a valid JObject.
PropriedadeProperty | DescriçãoDescription | NecessárioRequired |
---|---|---|
typetype | A propriedade type deve ser definida como: AzureFunctionThe type property must be set to: AzureFunction | simyes |
url do aplicativo de funçãofunction app url | URL para o Aplicativo de Funções do Azure.URL for the Azure Function App. O formato é https://<accountname>.azurewebsites.net .Format is https://<accountname>.azurewebsites.net . Essa URL é o valor na seção URL ao exibir o Aplicativo de funções no portal do AzureThis URL is the value under URL section when viewing your Function App in the Azure portal |
simyes |
teclas de funçãofunction key | Tecla de acesso para o Azure Function.Access key for the Azure Function. Clique na seção Gerenciar seção para a função respectiva e copie-a na Tecla de Função ou na Tecla Host.Click on the Manage section for the respective function, and copy either the Function Key or the Host key. Saiba mais aqui: Gatilhos e associações HTTP do Azure FunctionsFind out more here: Azure Functions HTTP triggers and bindings | simyes |
Atividade do Azure FunctionAzure Function activity
PropriedadeProperty | DescriçãoDescription | Valores permitidosAllowed values | NecessáriaRequired |
---|---|---|---|
namename | Nome da atividade no pipelineName of the activity in the pipeline | StringString | simyes |
tipotype | O tipo de atividade é 'AzureFunctionActivity'Type of activity is ‘AzureFunctionActivity’ | StringString | simyes |
serviço vinculadolinked service | O serviço de função do Azure vinculado para o Aplicativo de funções correspondente do AzureThe Azure Function linked service for the corresponding Azure Function App | Referência de serviço vinculadoLinked service reference | simyes |
nome da funçãofunction name | Nome da função no Aplicativo de funções do Azure que essa atividade chamaName of the function in the Azure Function App that this activity calls | StringString | simyes |
methodmethod | Método da API REST para a chamada de funçãoREST API method for the function call | Tipos de cadeia de caracteres com suporte: "GET", "POST", "PUT"String Supported Types: "GET", "POST", "PUT" | simyes |
headerheader | Cabeçalhos que são enviados para a solicitação.Headers that are sent to the request. Por exemplo, para definir o idioma e o tipo em uma solicitação: "cabeçalhos": { "Accept-Language": "en-us", "Content-Type": "application/json" }For example, to set the language and type on a request: "headers": { "Accept-Language": "en-us", "Content-Type": "application/json" } | Cadeia de caracteres (ou expressão com um resultType de cadeia de caracteres)String (or expression with resultType of string) | NãoNo |
bodybody | corpo que é enviado junto com a solicitação para o método de api de funçãobody that is sent along with the request to the function api method | Cadeia de caracteres (ou expressão com um resultType de cadeia de caracteres) ou objeto.String (or expression with resultType of string) or object. | Necessário para os métodos PUT/POSTRequired for PUT/POST methods |
Consulte o esquema da carga de solicitação na seção Esquema de carga de solicitação.See the schema of the request payload in Request payload schema section.
Roteamento e consultasRouting and queries
A atividade do Azure Function dá suporte a roteamento.The Azure Function Activity supports routing. Por exemplo, se a função do Azure tiver o ponto de extremidade https://functionAPP.azurewebsites.net/api/<functionName>/<value>?code=<secret>
, o functionName
para usar na atividade de função do Azure é <functionName>/<value>
.For example, if your Azure Function has the endpoint https://functionAPP.azurewebsites.net/api/<functionName>/<value>?code=<secret>
, then the functionName
to use in the Azure Function Activity is <functionName>/<value>
. Você pode parametrizar essa função para fornecer as desejadas functionName
em tempo de execução.You can parameterize this function to provide the desired functionName
at runtime.
A atividade do Azure Function também dá suporte a consultas. The Azure Function Activity also supports queries. Uma consulta deve ser incluída como parte do functionName
.A query has to be included as part of the functionName
. Por exemplo, quando o nome da função é HttpTriggerCSharp
e a consulta que você deseja incluir é name=hello
, você pode construir o functionName
na atividade de função do Azure como HttpTriggerCSharp?name=hello
.For example, when the function name is HttpTriggerCSharp
and the query that you want to include is name=hello
, then you can construct the functionName
in the Azure Function Activity as HttpTriggerCSharp?name=hello
. Essa função pode ser parametrizada para que o valor possa ser determinado em tempo de execução.This function can be parameterized so the value can be determined at runtime.
Funções de tempo limite e execução longaTimeout and long running functions
Azure Functions o tempo limite após 230 segundos, independentemente da functionTimeout
configuração que você definiu nas configurações.Azure Functions times out after 230 seconds regardless of the functionTimeout
setting you've configured in the settings. Para obter mais informações, consulte este artigo.For more information, see this article. Para contornar esse comportamento, siga um padrão assíncrono ou use Durable Functions.To work around this behavior, follow an async pattern or use Durable Functions. A vantagem do Durable Functions é que eles oferecem seu próprio mecanismo de controle de estado, portanto, você não precisará implementar o seu.The benefit of Durable Functions is that they offer their own state-tracking mechanism, so you won't have to implement your own.
Saiba mais sobre Durable Functions neste artigo.Learn more about Durable Functions in this article. Você pode configurar uma atividade do Azure function para chamar a função durável, que retornará uma resposta com um URI diferente, como Este exemplo.You can set up an Azure Function Activity to call the Durable Function, which will return a response with a different URI, such as this example. Como statusQueryGetUri
o retorna o status HTTP 202 enquanto a função está em execução, você pode sondar o status da função usando uma atividade da Web.Because statusQueryGetUri
returns HTTP Status 202 while the function is running, you can poll the status of the function by using a Web Activity. Basta configurar uma atividade da Web com o url
campo definido como @activity('<AzureFunctionActivityName>').output.statusQueryGetUri
.Simply set up a Web Activity with the url
field set to @activity('<AzureFunctionActivityName>').output.statusQueryGetUri
. Quando a função durável for concluída, a saída da função será a saída da atividade da Web.When the Durable Function completes, the output of the function will be the output of the Web Activity.
AmostraSample
Você pode encontrar um exemplo de um Data Factory que usa uma função do Azure para extrair o conteúdo de um arquivo tar aqui.You can find a sample of a Data Factory that uses an Azure Function to extract the content of a tar file here.
Próximas etapasNext steps
Saiba mais sobre as atividades no Data Factory no Pipelines e atividades no Azure Data Factory.Learn more about activities in Data Factory in Pipelines and activities in Azure Data Factory.