AzureFunctionAppContainer@1 - 容器 v1 任务的Azure Functions

使用 Docker 容器更新函数应用。

使用 Docker 容器更新函数应用。

语法

# Azure Functions for container v1
# Update a function app with a Docker container.
- task: AzureFunctionAppContainer@1
  inputs:
    azureSubscription: # string. Required. Azure subscription. 
    appName: # string. Required. App name. 
    #deployToSlotOrASE: false # boolean. Deploy to Slot or App Service Environment. Default: false.
    #resourceGroupName: # string. Required when deployToSlotOrASE = true. Resource group. 
    #slotName: 'production' # string. Required when deployToSlotOrASE = true. Slot. Default: production.
    imageName: # string. Required. Image name. 
    #containerCommand: # string. Startup command. 
  # Application and Configuration Settings
    #appSettings: # string. App settings. 
    #configurationStrings: # string. Configuration settings.
# Azure Function for container v1
# Update Function Apps with Docker containers.
- task: AzureFunctionAppContainer@1
  inputs:
    azureSubscription: # string. Required. Azure subscription. 
    appName: # string. Required. App name. 
    #deployToSlotOrASE: false # boolean. Deploy to Slot or App Service Environment. Default: false.
    #resourceGroupName: # string. Required when deployToSlotOrASE = true. Resource group. 
    #slotName: 'production' # string. Required when deployToSlotOrASE = true. Slot. Default: production.
    imageName: # string. Required. Image name. 
    #containerCommand: # string. Startup command. 
  # Application and Configuration Settings
    #appSettings: # string. App settings. 
    #configurationStrings: # string. Configuration settings.

输入

azureSubscription - Azure 订阅
string. 必需。

为部署选择 Azure 资源管理器订阅


appName - 应用名称
string. 必需。

用于容器的函数应用的名称。


deployToSlotOrASE - 部署到槽或应用服务环境
boolean. 默认值:false

将此输入设置为 以true部署到现有部署槽位或Azure 应用服务环境。 该任务需要两个目标的资源组名称。 对于部署槽选项,默认部署到 生产 槽,也可以指定任何其他现有槽名称。 如果部署目标是Azure 应用服务环境,请将槽名称保留为生产,并指定资源组名称。


resourceGroupName - 资源组
string. 当 deployToSlotOrASE = true 时,需要此选项。

包含用于容器的函数应用的资源组的名称。


slotName -
string. 当 deployToSlotOrASE = true 时,需要此选项。 默认值:production

输入或选择现有槽,不包括 生产 槽。


imageName - 映像名称
string. 必需。

特定注册表或命名空间的全局唯一顶级域名。

注意: 完全限定的映像名称的格式为: <registry or namespace> <repository> <tag>。 例如,myregistry.azurecr.io/nginx:latest


containerCommand - 启动命令
string.

部署后执行的启动命令。 例如, dotnet rundotnet filename.dll.


appSettings - 应用设置
string.

使用语法 -key value (输入应用程序设置,例如: -Port 5000-RequestTimeout 5000-WEBSITE_TIME_ZONE) 。 将包含空格的值括在双引号 (例如: "Eastern Standard Time") 。


configurationStrings - 配置设置
string.

使用语法 -key value (输入配置字符串,例如: -phpVersion 5.6-linuxFxVersion: node|6.11) 。 将包含空格的值括在双引号中。


任务控件选项

除任务输入外,所有任务都有控制选项。 有关详细信息,请参阅 控制选项和常见任务属性

输出变量

此任务定义以下 输出变量,可在下游步骤、作业和阶段中使用。

AppServiceApplicationUrl
所选App 服务的应用程序 URL。

备注

使用此任务使用 自定义映像在 Linux 上部署 Azure 函数。

错误:无法提取 Azure 的访问令牌。 验证所使用的服务主体是否有效且未过期。

该任务使用服务连接中的服务主体向 Azure 进行身份验证。 如果服务主体已过期或对App 服务没有权限,则任务失败并出现此错误。 验证所使用的服务主体的有效期以及该主体是否存在于应用注册中。 有关详细信息,请参阅使用基于角色的访问控制来管理对 Azure 订阅资源的访问此博客文章 还包含有关使用服务主体身份验证的详细信息。

SSL 错误

如果要在 App 服务 中使用证书,该证书必须由受信任的证书颁发机构签名。 如果 Web 应用显示证书验证错误,可能是因为使用了自签名证书。 将名为 的 VSTS_ARM_REST_IGNORE_SSL_ERRORS 变量设置为生成或发布管道中的值 true ,以解决错误。

发布长时间挂起,然后失败

此问题可能是App 服务计划中容量不足造成的。 若要解决此问题,可以纵向扩展 App 服务 实例以增加可用的 CPU、RAM 和磁盘空间,或者尝试使用其他App 服务计划。

5xx 错误代码

如果看到 5xx 错误,检查 Azure 服务的状态

Azure 函数突然停止工作

如果自上次部署以来已超过一年时间,Azure Functions可能会突然停止工作。 如果在“deploymentMethod”中使用“RunFromPackage”进行部署,则会生成过期日期为 1 年的 SAS,并在应用程序配置中将其设置为“WEBSITE_RUN_FROM_PACKAGE”的值。 Azure Functions使用此 SAS 来引用用于执行函数的包文件,因此如果 SAS 已过期,则不会执行函数。 若要解决此问题,请再次部署以生成过期日期为一年的 SAS。

应如何配置服务连接?

此任务需要 Azure 资源管理器 服务连接

如何使用 Application Insights 配置 Web 作业部署?

部署到App 服务时,如果已配置 Application Insights 并且已启用 Remove additional files at destination,则还需要启用 Exclude files from the App_Data folder。 启用此选项可使 Application Insights 扩展处于安全状态。 此步骤是必需的,因为 Application Insights 连续 WebJob 已安装到 App_Data 文件夹中。

在部署到 App 服务 时,如果代理位于代理后面,应如何配置代理?

如果自承载代理需要 Web 代理,可以在配置期间通知代理有关代理的信息。 这样,代理就可以连接到 Azure Pipelines 或通过代理Azure DevOps Server。 详细了解如何在 Web 代理后面运行自承载代理

示例

此示例使用容器在 Linux 上部署Azure Functions:


variables:
  imageName: contoso.azurecr.io/azurefunctions-containers:$(build.buildId)
  azureSubscription: Contoso
  # To ignore SSL error uncomment the following variable
  # VSTS_ARM_REST_IGNORE_SSL_ERRORS: true

steps:
- task: AzureFunctionAppContainer@1
  displayName: Azure Function App on Container deploy
  inputs:
    azureSubscription: $(azureSubscription)
    appName: functionappcontainers
    imageName: $(imageName)

要求

要求 说明
管道类型 YAML、经典版本、经典版本
运行平台 Agent、DeploymentGroup
需求
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任意
可设置变量 任意
代理版本 2.104.1 或更高版本
任务类别 部署