您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

使用 Azure 逻辑应用连接到本地文件系统Connect to on-premises file systems with Azure Logic Apps

使用 Azure 逻辑应用和文件系统连接器,可以创建在本地文件共享上创建和管理文件的自动化任务与工作流,例如:With Azure Logic Apps and the File System connector, you can create automated tasks and workflows that create and manage files on an on-premises file share, for example:

  • 创建、获取、追加、更新和删除文件。Create, get, append, update, and delete files.

  • 列出文件夹或根文件夹中的文件。List files in folders or root folders.

  • 获取文件内容和元数据。Get file content and metadata.

    重要

    文件系统连接器目前仅支持 Windows 操作系统上的 Windows 文件系统。The File System connector currently supports only Windows file systems on Windows operating systems.

本文介绍如何根据本示例方案所述连接到本地文件系统:将上传至 Dropbox 的文件复制到文件共享,然后发送一封电子邮件。This article shows how you can connect to an on-premises file system as described by this example scenario: copy a file that's uploaded to Dropbox to a file share, and then send an email. 为了安全连接和访问本地系统,逻辑应用将使用本地数据网关To securely connect and access on-premises systems, logic apps use the on-premises data gateway. 如果你不熟悉逻辑应用,请查看什么是 Azure 逻辑应用?If you're new to logic apps, review What is Azure Logic Apps?. 如需特定于连接器的技术信息,请参阅文件系统连接器参考For connector-specific technical information, see the File System connector reference.

先决条件Prerequisites

  • Azure 订阅。An Azure subscription. 如果没有 Azure 订阅,请注册一个免费 Azure 帐户If you don't have an Azure subscription, sign up for a free Azure account.

  • 将逻辑应用连接到本地系统(例如文件系统服务器)之前,需要安装并设置本地数据网关Before you can connect logic apps to on-premises systems such as your file system server, you need to install and set up an on-premises data gateway. 这样,便可以指定在从逻辑应用创建文件系统连接时要使用网关安装。That way, you can specify to use your gateway installation when you create the file system connection from your logic app.

  • 一个 Dropbox 帐户,可以在注册后免费获取。A Dropbox account, which you can sign up for free. 帐户凭据是在逻辑应用和 Dropbox 帐户之间创建连接所必需的。Your account credentials are necessary for creating a connection between your logic app and your Dropbox account.

  • 访问特定的计算机,其中的文件系统是你需要使用的。Access to the computer that has the file system you want to use. 例如,如果在与文件系统相同的计算机上安装数据网关,则需要该计算机的帐户凭据。For example, if you install the data gateway on the same computer as your file system, you need the account credentials for that computer.

  • 逻辑应用支持的提供商(例如 Office 365 Outlook、Outlook.com 或 Gmail)提供的电子邮件帐户。An email account from a provider that's supported by Logic Apps, such as Office 365 Outlook, Outlook.com, or Gmail. 至于其他提供商,请查看此处的连接器列表For other providers, review the connectors list here. 此逻辑应用使用工作或学校帐户。This logic app uses a work or school account. 如果使用其他电子邮件帐户,整个步骤仍然是相同的,但 UI 可能稍有不同。If you use another email account, the overall steps are the same, but your UI might slightly differ.

    重要

    如果要使用 Gmail 连接器,则只有 G-Suite 商业帐户可以在逻辑应用中不受限制地使用此连接器。If you want to use the Gmail connector, only G-Suite business accounts can use this connector without restriction in logic apps. 如果有 Gmail 用户帐户,则只能将此连接器与 Google 批准的特定服务一起使用,也可以创建用于通过 Gmail 连接器进行身份验证的 Google 客户端应用If you have a Gmail consumer account, you can use this connector with only specific Google-approved services, or you can create a Google client app to use for authentication with your Gmail connector. 有关详细信息,请参阅 Azure 逻辑应用中 Google 连接器的数据安全和隐私策略For more information, see Data security and privacy policies for Google connectors in Azure Logic Apps.

  • 有关如何创建逻辑应用的基本知识。Basic knowledge about how to create logic apps. 对于本示例,需要一个空白逻辑应用。For this example, you need a blank logic app.

添加触发器Add trigger

首次添加连接到服务或系统的触发器或操作时,逻辑应用设计器将提示你通过提供必要的信息(具体取决于连接)来创建连接,例如:When you add a trigger or action that connects to a service or system for the first time, the Logic App Designer prompts you to create a connection by providing the necessary information, which varies based on the connection, for example:

  • 要用于新连接的名称A name to use for the new connection
  • 服务器或系统名称The server or system name
  • 用户凭据或帐户凭据Your user or account credentials
  • 要使用的身份验证类型The authentication type to use
  • 你之前连接到本地数据源时创建的数据网关的 Azure 订阅和名称The Azure subscription and name for the data gateway that you previously create when connecting to on-premises data sources
  1. 登录到 Azure 门户,在逻辑应用设计器中打开逻辑应用(如果尚未打开)。Sign in to the Azure portal, and open your logic app in Logic App Designer, if not open already.

  2. 在搜索框中,输入“dropbox”作为筛选器。In the search box, enter "dropbox" as your filter. 从触发器列表中选择此触发器:创建文件时From the triggers list, select this trigger: When a file is created

    选择 Dropbox 触发器

  3. 使用 Dropbox 帐户凭据登录,并授权 Azure 逻辑应用访问你的 Dropbox 数据。Sign in with your Dropbox account credentials, and authorize access to your Dropbox data for Azure Logic Apps.

  4. 提供触发器的所需信息。Provide the required information for your trigger.

    Dropbox 触发器

添加操作Add actions

  1. 在触发器下,选择“下一步”。Under the trigger, choose Next step. 在搜索框中,输入“文件系统”作为筛选器。In the search box, enter "file system" as your filter. 在操作列表中选择此操作:创建文件From the actions list, select this action: Create file

    查找文件系统连接器

  2. 如果还没有到文件系统的连接,系统会提示创建连接。If you don't already have a connection to your file system, you're prompted to create a connection.

    创建连接

    属性Property 必须Required Value 说明Description
    连接名称Connection Name Yes <connection-name><connection-name> 连接使用的名称The name you want for your connection
    根文件夹Root folder Yes <root-folder-name><root-folder-name> 文件系统的根文件夹,例如,如果安装了本地数据网关,比如安装了本地数据网关的计算机上的本地文件夹,或者计算机可以访问的网络共享文件夹。The root folder for your file system, for example, if you installed your on-premises data gateway such as a local folder on the computer where the on-premises data gateway is installed, or the folder for a network share that the computer can access.

    例如: \\PublicShare\\DropboxFilesFor example: \\PublicShare\\DropboxFiles

    根文件夹是主要的父文件夹,用作所有与文件有关的操作的相对路径。The root folder is the main parent folder, which is used for relative paths for all file-related actions.

    身份验证类型Authentication Type No <auth-type><auth-type> 文件系统使用的身份验证类型:WindowsThe type of authentication that your file system uses: Windows
    用户名Username Yes <domain>\<username> <domain>\<username>

    -或--or-

    <local-computer>\<username><local-computer>\<username>

    具有文件系统文件夹的计算机的用户名。The username for the computer where you have your file system folder.

    如果文件系统文件夹与本地数据网关在同一台计算机上,则可使用 <local-computer>\<username>。If your file system folder is on the same computer as the on-premises data gateway, you can use <local-computer>\<username>.

    密码Password Yes <your-password><your-password> 拥有文件系统的计算机密码The password for the computer where you have your file system
    gatewaygateway Yes <installed-gateway-name><installed-gateway-name> 以前安装的网关的名称The name for your previously installed gateway
  3. 完成后,选择“创建”。When you're done, choose Create.

    逻辑应用会配置和测试连接,以确保连接正常运行。Logic Apps configures and tests your connection, making sure that the connection works properly. 如果正确建立连接,会显示用于之前所选操作的选项。If the connection is set up correctly, options appear for the action that you previously selected.

  4. 在“创建文件”操作中,提供用于将文件从 Dropbox 复制到本地文件共享中的根文件夹的详细信息。In the Create file action, provide the details for copying files from Dropbox to the root folder in your on-premises file share. 若要添加前面步骤的输出,请在框中单击,然后在显示动态内容列表时从可用字段中进行选择。To add outputs from previous steps, click inside the boxes, and select from available fields when the dynamic content list appears.

    创建文件操作

  5. 现在添加一个发送电子邮件的 Outlook 操作,使相应的用户知道已创建新文件。Now, add an Outlook action that sends an email so the appropriate users know about the new file. 输入收件人、标题和电子邮件正文。Enter the recipients, title, and body of the email. 若要测试,可以使用自己的电子邮件地址。For testing, you can use your own email address.

    发送电子邮件操作

  6. 保存逻辑应用。Save your logic app. 通过将文件上传到 Dropbox 来测试应用。Test your app by uploading a file to Dropbox.

    逻辑应用应会将该文件复制到本地文件共享,并向收件人发送一封有关已复制的文件的电子邮件。Your logic app should copy the file to your on-premises file share, and send the recipients an email about the copied file.

连接器参考Connector reference

有关此连接器的更多技术详细信息,例如触发器、操作和限制(如此连接器的 Swagger 文件所述),请参阅连接器的参考页For more technical details about this connector, such as triggers, actions, and limits as described by the connector's Swagger file, see the connector's reference page.

备注

对于 integration service 环境 中的逻辑应用 (ISE) ,此连接器的基于 ise 标记的版本改为使用 ise 消息限制For logic apps in an integration service environment (ISE), this connector's ISE-labeled version uses the ISE message limits instead.

后续步骤Next steps