安装 Azure Functions 运行时预览版 2Install the Azure Functions Runtime preview 2

重要

Azure Functions 运行时预览版 2 仅支持版本 1.x 的 Azure Functions 运行时。The Azure Functions Runtime preview 2 supports only version 1.x of the Azure Functions runtime. 此预览功能不会更新为支持运行时版本 2.x 和更高版本,也没有计划在将来更新。This preview feature is not being updated to support version 2.x and higher of the runtime, and no future updates are planned.

若要安装 Azure Functions 运行时预览版 2,必须执行以下步骤:If you would like to install the Azure Functions Runtime preview 2, follow these steps:

  1. 确保计算机满足最低要求。Ensure your machine passes the minimum requirements.
  2. 下载 Azure Functions 运行时预览版安装程序Download the Azure Functions Runtime Preview Installer.
  3. 卸载 Azure Functions 运行时预览版 1。Uninstall the Azure Functions Runtime preview 1.
  4. 安装 Azure Functions 运行时预览版 2。Install the Azure Functions Runtime preview 2.
  5. 完成 Azure Functions 运行时预览版 2 的配置。Complete the configuration of the Azure Functions Runtime preview 2.
  6. 在 Azure Functions 运行时预览版中创建第一个函数Create your first function in Azure Functions Runtime Preview

先决条件Prerequisites

在安装 Azure Functions 运行时预览版之前,必须准备好以下资源:Before you install the Azure Functions Runtime preview, you must have the following resources available:

  1. 运行着 Microsoft Windows Server 2016 或 Microsoft Windows 10 Creators Update(专业版或企业版)的计算机。A machine running Microsoft Windows Server 2016 or Microsoft Windows 10 Creators Update (Professional or Enterprise Edition).
  2. 在网络中运行的一个 SQL Server 实例。A SQL Server instance running within your network. 最低版本要求是 SQL Server Express。Minimum edition required is SQL Server Express.

卸载以前的版本Uninstall Previous Version

如果之前已安装 Azure Functions 运行时预览版,则必须将其卸载,然后安装最新版本。If you have previously installed the Azure Functions Runtime preview, you must uninstall before installing the latest release. 可通过 Windows 中的“添加/删除程序”卸载 Azure Functions 运行时预览版。Uninstall the Azure Functions Runtime preview by removing the program in Add/Remove Programs in Windows.

安装 Azure Functions 运行时预览版Install the Azure Functions Runtime Preview

Azure Functions 运行时预览版安装程序会引导完成 Azure Functions 运行时预览版管理角色和辅助角色的安装。The Azure Functions Runtime Preview Installer guides you through the installation of the Azure Functions Runtime preview Management and Worker Roles. 可以将管理角色和辅助角色安装在同一计算机上。It is possible to install the Management and Worker role on the same machine. 但是,随着添加更多的函数应用,必须在附加计算机上部署更多辅助角色以便能够将函数扩展到多个辅助角色。However, as you add more function apps, you must deploy more worker roles on additional machines to be able to scale your functions onto multiple workers.

将管理角色和辅助角色安装在同一计算机上Install the Management and Worker Role on the same machine

  1. 运行 Azure Functions 运行时预览版安装程序。Run the Azure Functions Runtime Preview Installer.

    Azure Functions 运行时预览版安装程序

  2. 单击“下一步” 。Click Next.

  3. 在阅读 EULA 的条款后,选中复选框以接受条款并单击“下一步” 以继续操作。Once you have read the terms of the EULA, check the box to accept the terms and click Next to advance.

  4. 选择要在此计算机上安装的角色“Functions 管理角色”和/或“Functions 辅助角色”并单击“下一步” 。Select the roles you want to install on this machine Functions Management Role and/or Functions Worker Role and click Next.

    Azure Functions 运行时预览版安装程序 - 角色选择

    备注

    可以在其他许多计算机上安装 Functions 辅助角色You can install the Functions Worker Role on many other machines. 为此,请按照这些说明进行操作,并且仅在安装程序中选择“Functions 辅助角色”。 To do so, follow these instructions, and only select Functions Worker Role in the installer.

  5. 单击“下一步”,让 Azure Functions 运行时安装向导开始在计算机上执行安装过程 。Click Next to have the Azure Functions Runtime Setup Wizard begin the installation process on your machine.

  6. 完成后,安装向导将启动“Azure Functions 运行时”配置工具 。Once complete, the setup wizard launches the Azure Functions Runtime configuration tool.

    Azure Functions 运行时预览版安装程序完成

    备注

    如果是在 Windows 10 上进行安装并且未启用容器功能,则 Azure Functions 运行时安装程序会提示重新启动计算机来完成安装。If you are installing on Windows 10 and the Container feature has not been previously enabled, the Azure Functions Runtime Setup prompts you to reboot your machine to complete the install.

配置 Azure Functions 运行时Configure the Azure Functions Runtime

若要完成 Azure Functions 运行时安装,必须完成配置。To complete the Azure Functions Runtime installation, you must complete the configuration.

  1. Azure Functions 运行时配置工具会显示计算机上安装了哪些角色。The Azure Functions Runtime configuration tool shows which roles are installed on your machine.

    Azure Functions 运行时预览版配置工具

  2. 单击“数据库” 选项卡,输入 SQL Server 实例的连接详细信息(包括指定数据库主密钥)并单击“应用” 。Click the Database tab, enter the connection details for your SQL Server instance, including specifying a Database master key, and click Apply. 需要与 SQL Server 实例建立连接,才能让 Azure Functions 运行时创建数据库来支持运行时。Connectivity to a SQL Server instance is required in order for the Azure Functions Runtime to create a database to support the Runtime.

    Azure Functions 运行时预览版数据库配置

  3. 单击“凭据”选项卡 。在此处,必须为托管所有函数应用的文件共享创建两个凭据。Click the Credentials tab. Here, you must create two new credentials for use with a file share for hosting all your function apps. 文件共享所有者文件共享用户指定用户名密码组合,并单击“应用” 。Specify User name and Password combinations for the file share owner and for the file share user, then click Apply.

    Azure Functions 运行时预览版凭据

  4. 单击“文件共享”选项卡。 在此处,必须指定文件共享位置的详细信息。Click the File Share tab. Here you must specify the details of the file share location. 系统可以创建文件共享,也可以选择一个现有文件共享并单击“应用”。 The file share can be created for you or you can use an existing File Share and click Apply. 如果选择了新的文件共享位置,则必须指定一个目录供 Azure Functions 运行时使用。If you select a new File Share location, you must specify a directory for use by the Azure Functions Runtime.

    Azure Functions 运行时预览版文件共享

  5. 单击“IIS”选项卡。 此选项卡显示 Azure Functions 运行时配置工具会在 IIS 中创建的网站的详细信息。Click the IIS tab. This tab shows the details of the websites in IIS that the Azure Functions Runtime configuration tool creates. 可以在此处为 Azure Functions 运行时预览版门户指定自定义的 DNS 名称。You may specify a custom DNS name here for the Azure Functions Runtime preview portal. 单击“应用” 以完成操作。Click Apply to complete.

    Azure Functions 运行时预览版 IIS

  6. 单击“服务”选项卡。 此选项卡显示 Azure Functions 运行时配置工具中的服务的状态。Click the Services tab. This tab shows the status of the services in your Azure Functions Runtime configuration tool. 完成初始配置后,如果 Azure Functions 主机激活服务未运行,请单击“启动服务” If the Azure Functions Host Activation Service is not running after initial configuration, click Start Service.

    Azure Functions 运行时预览版配置完成

  7. 使用 https://<machinename>.<domain>/ 浏览到 Azure Functions 运行时门户Browse to the Azure Functions Runtime Portal as https://<machinename>.<domain>/.

    Azure Functions 运行时预览版门户

在 Azure Functions 运行时预览版中创建第一个函数Create your first function in Azure Functions Runtime preview

在 Azure Functions 运行时预览版中创建第一个函数To create your first function in Azure Functions Runtime preview

  1. https://<machinename>.<domain> 的形式浏览到 Azure Functions 运行时门户,例如 https://mycomputer.mydomain.comBrowse to the Azure Functions Runtime Portal as https://<machinename>.<domain> for example https://mycomputer.mydomain.com.

  2. 系统会提示登录。如果是在域中部署的,请使用帐户用户名和密码登录;否则,请使用本地帐户用户名和密码登录到门户。You are prompted to Log in, if deployed in a domain use your domain account username and password, otherwise use your local account username and password to log in to the portal.

    Azure Functions 运行时预览版门户登录

  3. 若要创建函数应用,必须创建订阅。To create function apps, you must create a Subscription. 在门户的左上角,单击订阅旁边的 + 选项。In the top left-hand corner of the portal, click the + option next to the subscriptions.

    Azure Functions 运行时预览版门户订阅

  4. 选择“DefaultPlan”,输入订阅名称,单击“创建” 。Choose DefaultPlan, enter a name for your Subscription, and click Create.

    Azure Functions 运行时预览版门户订阅计划和名称

  5. 所有函数应用列在门户的左窗格中。All of your function apps are listed in the left-hand pane of the portal. 若要创建新的函数应用,请选择标题“函数应用”,单击 + 选项 。To create a new Function App, select the heading Function Apps and click the + option.

  6. 输入函数应用的名称,选择正确的订阅,选择想要对其编程的 Azure Functions 运行时版本,并单击“创建” Enter a name for your function app, select the correct Subscription, choose which version of the Azure Functions runtime you wish to program against and click Create

    Azure Functions 运行时预览版门户 - 新建函数应用

  7. 新函数应用将列入门户的左窗格中。Your new function app is listed in the left-hand pane of the portal. 选择“函数”,单击门户中间窗格顶部的“新建函数” 。Select Functions and then click New Function at the top of the center pane in the portal.

    Azure Functions 运行时预览版模板

  8. 选择“计时器触发器”函数,在右侧浮出控件中为函数命名,将“计划”更改为 */5 * * * * *(此 cron 表达式可让计时器函数每隔五秒执行一次),并单击“创建” Select the Timer Trigger function, in the right-hand flyout name your function and change the Schedule to */5 * * * * * (this cron expression causes your timer function to execute every five seconds), and click Create

    Azure Functions 运行时预览版 - 新计时器函数配置

  9. 现已创建函数。Your function has now been created. 可以通过展开门户底部的“日志”窗格查看函数应用的执行日志 。You can view the execution log of your Function app by expanding the log pane at the bottom of the portal.

    Azure Functions 运行时预览版 - 函数执行