Uredi

Deli z drugimi prek


Connect to an FTP server from workflows in Azure Logic Apps

Applies to: Azure Logic Apps (Consumption + Standard)

This article shows how to access your File Transfer Protocol (FTP) server from a workflow in Azure Logic Apps with the FTP connector. You can then create automated workflows that run when triggered by events in your FTP server or in other systems and run actions to manage files on your FTP server.

For example, your workflow can start with an FTP trigger that monitors and responds to events on your FTP server. The trigger makes the outputs available to subsequent actions in your workflow. Your workflow can run FTP actions that create, send, receive, and manage files through your FTP server account using the following specific tasks:

  • Monitor when files are added or changed.
  • Create, copy, delete, list, and update files.
  • Get file metadata and content.
  • Manage folders.

If you're new to Azure Logic Apps, review the following get started documentation:

Connector technical reference

The FTP connector has different versions, based on logic app type and host environment.

Logic app type (plan) Environment Connector version
Consumption Multitenant Azure Logic Apps Managed connector, which appears in the connector gallery under Runtime > Shared. For more information, review the following documentation:

- FTP managed connector reference
- Managed connectors in Azure Logic Apps
Standard Single-tenant Azure Logic Apps and App Service Environment v3 (Windows plans only) Managed connector (Azure-hosted), which appears in the connector gallery under Runtime > Shared, and built-in connector, which appears in the connector gallery under Runtime > In App and is service provider based. The built-in connector can directly access Azure virtual networks with a connection string. For more information, review the following documentation:

- FTP managed connector reference
- FTP built-in connector operations section later in this article
- Managed connectors in Azure Logic Apps
- Built-in connectors in Azure Logic Apps

Limitations

  • Capacity and throughput

    • Built-in connector for Standard workflows:

      By default, FTP actions can read or write files that are 200 MB or smaller. Currently, the FTP built-in connector doesn't support chunking.

    • Managed or Azure-hosted connector for Consumption and Standard workflows

      By default, FTP actions can read or write files that are 50 MB or smaller. To handle files larger than 50 MB, FTP actions support message chunking. The Get file content action implicitly uses chunking.

  • Triggers for the FTP managed or Azure-hosted connector might experience missing, incomplete, or delayed results when the "last modified" timestamp is preserved. On the other hand, the FTP built-in connector trigger in Standard logic app workflows doesn't have this limitation. For more information, review the FTP connector's Limitations section.

  • The FTP managed or Azure-hosted connector can create a limited number of connections to the FTP server, based on the connection capacity in the Azure region where your logic app resource exists. If this limit poses a problem in a Consumption logic app workflow, consider creating a Standard logic app workflow and use the FTP built-in connector instead.

Prerequisites

  • An Azure account and subscription. If you don't have an Azure subscription, sign up for a free Azure account.

  • The logic app workflow where you want to access your FTP account. To start your workflow with an FTP trigger, you have to start with a blank workflow. To use an FTP action, start your workflow with another trigger, such as the Recurrence trigger.

  • For more requirements that apply to both the FTP managed connector and built-in connector, review the FTP managed connector reference - Requirements.

Known issues

By default, triggers that return an array have a Split On setting that's already enabled. With this setting enabled, the trigger automatically debatches the array by internally creating a separate workflow instance to process each array item. All the workflow instances run in parallel so that the array items are processed at the same time.

However, when the Split On setting is enabled, managed connector triggers return the outputs for all the array items as lists. Any subsequent actions that reference these outputs have to first handle these outputs as lists. To handle each array item individually, you can add extra actions. For example, to iterate through these array items, you can use a For each loop. For triggers that return only metadata or properties, use an action that gets the array item's metadata first, and then use an action to get the items contents.

You have to apply this approach only for managed connector triggers, not built-in connector triggers that return outputs for one array item at a time when the Split On setting is enabled.

For example, suppose you have managed connector trigger named When a file is added or modified (properties only) that returns the metadata or properties for the new or updated files as arrays. To get the metadata separately for each file, you might use a For each loop that iterates through the array. In this loop, use the following managed connector actions in the specified order:

  1. Get file metadata to get each file's metadata.

  2. Get file content action to get each file's content.

Add an FTP trigger

A Consumption logic app workflow can use only the FTP managed connector. However, a Standard logic app workflow can use the FTP managed connector and the FTP built-in connector. In a Standard logic app workflow, managed connectors are also labeled as Azure connectors.

The FTP managed connector and built-in connector each have only one trigger available:

  • Managed connector trigger: The FTP trigger named When a file is added or modified (properties only) runs a Consumption or Standard logic app workflow when one or more files are added or changed in a folder on the FTP server. This trigger gets only the file properties or metadata, not the file content. However, to get the file content, your workflow can follow this trigger with other FTP actions.

    For more information about this trigger, review When a file is added or modified (properties only).

  • Built-in connector trigger: The FTP trigger named When a file is added or updated runs a Standard logic app workflow when one or more files are added or changed in a folder on the FTP server. This trigger gets only the file properties or metadata, not the file content. However, to get the content, your workflow can follow this trigger with other FTP actions. For more information about this trigger, review When a file is added or updated.

The following steps use the Azure portal, but with the appropriate Azure Logic Apps extension, you can also use the following tools to create and edit logic app workflows:

  1. In the Azure portal, and open your blank logic app workflow in the designer.

  2. On the designer, under the search box, select Standard. In the search box, enter ftp.

  3. From the triggers list, select the trigger named When a filed is added or modified (properties only).

    Screenshot shows Azure portal, Consumption workflow designer, and FTP trigger selected.

  4. Provide the information for your connection. When you're done, select Create.

    Note

    By default, this connector transfers files in text format. To transfer files in binary format, for example, where and when encoding is used, select the binary transport option.

    Screenshot shows Consumption workflow designer and FTP connection profile.

  5. After the trigger information box appears, find the folder that you want to monitor for new or edited files.

    1. In the Folder box, select the folder icon to view the folder directory.

    2. Select the right angle arrow (>). Browse to the folder that you want, and then select the folder.

    Screenshot shows Consumption workflow designer, FTP trigger, and "Folder" property where browsing for folder to select.

    Your selected folder appears in the Folder box.

    Screenshot shows Consumption workflow designer, FTP trigger, and "Folder" property with selected folder.

  6. When you're done, save your workflow.

When you save your workflow, this step automatically publishes your updates to your deployed logic app, which is live in Azure. With only a trigger, your workflow just checks the FTP server based on your specified schedule. You have to add an action that responds to the trigger and does something with the trigger outputs.

Add an FTP action

A Consumption logic app workflow can use only the FTP managed connector. However, a Standard logic app workflow can use the FTP managed connector and the FTP built-in connector. Each version has multiple actions. For example, both managed and built-in connector versions have their own actions to get file metadata and get file content.

  • Managed connector actions: These actions run in a Consumption or Standard logic app workflow.

  • Built-in connector actions: These actions run only in a Standard logic app workflow.

The following steps use the Azure portal, but with the appropriate Azure Logic Apps extension, you can also use the following tools to create and edit logic app workflows:

Before you can use an FTP action, your workflow must already start with a trigger, which can be any kind that you choose. For example, you can use the generic Recurrence built-in trigger to start your workflow on specific schedule.

  1. In the Azure portal, and open your logic app workflow in the designer.

  2. Find and select the FTP action that you want to use.

    This example continues with the action named Get file metadata so you can get the metadata for a single array item.

    1. On the designer, under the trigger or any other actions, select New step.

    2. Under the Choose an operation search box, select Standard.

    3. In the search box, enter ftp get file metadata.

    4. From the actions list, select the action named Get file metadata.

    Screenshot shows the Azure portal, Consumption workflow designer, search box with "ftp get file metadata" entered, and "Get file metadata" action selected.

  3. If necessary, provide the information for your connection. When you're done, select Create.

    Note

    By default, this connector transfers files in text format. To transfer files in binary format, for example, where and when encoding is used, select the binary transport option.

    Screenshot shows Consumption workflow designer and FTP connection profile for an action.

  4. After the Get file metadata action information box appears, click inside the File box so that the dynamic content list opens.

    You can now select outputs from the preceding trigger.

  5. In the dynamic content list, under When a file is added or modified, select List of Files Id.

    Screenshot shows Consumption workflow designer, "Get file metadata" action, dynamic content list opened, and "List of Files Id" selected.

    The File property now references the List of Files Id trigger output.

  6. On the designer, under the Get file metadata action, select New step.

  7. Under the Choose an operation search box, select Standard.

  8. In the search box, enter ftp get file content.

  9. From the actions list, select the action named Get file content.

    Screenshot shows the Azure portal, Consumption workflow designer, search box with "ftp get file content" entered, and "Get file content" action selected.

  10. After the Get file content action information box appears, click inside the File box so that the dynamic content list opens.

    You can now select outputs from the preceding trigger and any other actions.

  11. In the dynamic content list, under Get file metadata, select Id, which references the file that was added or updated.

    Screenshot shows Consumption workflow designer, "Get file content" action, and "File" property with dynamic content list opened and "Id" property selected.

    The File property now references the Id action output.

    Screenshot shows Consumption workflow designer, "Get file content" action, and "File" property with "Id" entered.

  12. When you're done, save your workflow. On the designer toolbar, select Save.

Test your workflow

To check that your workflow returns the content that you expect, add another action that sends you the content from the added or updated file. This example uses the Office 365 Outlook action named Send an email.

  1. Under the Get file content action, add the Office 365 Outlook action named Send an email. If you have an Outlook.com account instead, add the Outlook.com Send an email action, and adjust the following steps accordingly.

    1. On the designer, under the Get file content action, select New step.

    2. Under the Choose an operation search box, select Standard.

    3. In the search box, enter office 365 outlook send an email. From the actions list, select the Office 365 Outlook action named Send an email.

    Screenshot shows Consumption workflow designer and "Send an email" action under all the other actions.

  2. If necessary, sign in to your email account.

  3. In the action information box, provide the required values and include any other parameters or properties that you want to test.

    For example, you can include the File content output from the Get file content action. To find this output, follow these steps:

    1. In the Get file content action, click inside the Body box so that the dynamic content list opens.

    2. In the dynamic content list, next to Get file content, select See more.

      Screenshot shows Consumption workflow designer, "Send an email" action, and dynamic content list opened with "See more" selected next to "Get file content".

    3. In the dynamic content list, under Get file content, select File Content.

      The Body property now references the File Content action output.

      Screenshot shows Consumption workflow designer, "Send an email" action, dynamic content list opened, and "File Content" action output selected.

  4. Save your logic app workflow.

  5. To run and trigger the workflow, on the designer toolbar, select Run Trigger > Run. Add a file to the FTP folder that your workflow monitors.

FTP built-in connector operations

The FTP built-in connector is available only for Standard logic app workflows and provides the following operations:

Trigger Description
When a file is added or updated Start a logic app workflow when a file is added or updated in the specified folder on the FTP server.

Note: This trigger gets only the file metadata or properties, not the file content. However, to get the content, your workflow can follow this trigger with the Get file content action.

Action Description
Create file Create a file using the specified file path and file content.
Delete file Delete a file using the specified file path.
Get file content Get the content of a file using the specified file path.
Get file metadata Get the metadata or properties of a file using the specified file path.
List files and subfolders in a folder Get a list of files and subfolders in the specified folder.
Update file Update a file using the specified file path and file content.

When a file is added or updated

Operation ID: whenFtpFilesAreAddedOrModified

This trigger starts a logic app workflow run when a file is added or updated in the specified folder on the FTP server. The trigger gets only the file metadata or properties, not any file content. However, to get the content, your workflow can follow this trigger with the Get file content action.

Parameters

Name Key Required Type Description
Folder path folderPath True string The folder path, relative to the root directory.
Number of files to return maxFileCount False integer The maximum number of files to return from a single trigger run. Valid values range from 1 - 100.

Note: By default, the Split On setting is enabled and forces this trigger to process each file individually in parallel.
Cutoff timestamp to ignore older files oldFileCutOffTimestamp False dateTime The cutoff time to use for ignoring older files. Use the timestamp format YYYY-MM-DDTHH:MM:SS. To disable this feature, leave this property empty.

Returns

When the trigger's Split On setting is enabled, the trigger returns the metadata or properties for one file at a time. Otherwise, the trigger returns an array that contains each file's metadata.

Name Type
List of files BlobMetadata

Create file

Operation ID: createFile

This action creates a file using the specified file path and file content. If the file already exists, this action overwrites that file.

Important

If you delete or rename a file on the FTP server immediately after creation within the same workflow, the operation might return an HTTP 404 error, which is by design. To avoid this problem, include a 1-minute delay before you delete or rename any newly created files. You can use the Delay action to add this delay to your workflow.

Parameters

Name Key Required Type Description
File path filePath True string The file path, including the file name extension if any, relative to the root directory.
File content fileContent True string The file content.

Returns

This action returns a BlobMetadata object named Body.

Name Type
File metadata File name string
File metadata File path string
File metadata File size string
File metadata BlobMetadata

Delete file

Operation ID: deleteFtpFile

This action deletes a file using the specified file path.

Parameters

Name Key Required Type Description
File path filePath True string The file path, including the file name extension if any, relative to the root directory.

Returns

None

Get file content

Operation ID: getFtpFileContent

This action gets the content of a file using the specified file path.

Parameters

Name Key Required Type Description
File path path True string The file path, including the file name extension if any, relative to the root directory.

Returns

This action returns the content of a file as a binary value named File content.

Name Type
File content Binary

Get file metadata

Operation ID: getFileMetadata

This action gets the metadata or properties of a file using the specified file path.

Parameters

Name Key Required Type Description
File path path True string The file path, including the file name extension if any, relative to the root directory.

Returns

This action returns the following outputs:

Name Type
File name string
File path string
File size string
Last updated time string
File metadata BlobMetadata

List files and subfolders in a folder

Operation ID: listFilesInFolder

This action gets a list of files and subfolders in the specified folder.

Parameters

Name Key Required Type Description
Folder path folderPath True string The folder path, relative to the root directory.
File content fileContent True string The content for the file

Returns

This action returns an array that's named Response and contains BlobMetadata objects.

Name Type
Response Array with BlobMetadata objects

Update file

Operation ID: updateFile

This action updates a file using the specified file path and file content.

Important

If you delete or rename a file on the FTP server immediately after creation within the same workflow, the operation might return an HTTP 404 error, which is by design. To avoid this problem, include a 1-minute delay before you delete or rename any newly created files. You can use the Delay action to add this delay to your workflow.

Parameters

Name Key Required Type Description
File path filePath True string The file path, including the file name extension if any, relative to the root directory.
File content fileContent True string The content for the file

Returns

This action returns a BlobMetadata object named Body.

Name Type
Body BlobMetadata

Next steps