共用方式為


AzureFunctionAppContainer@1 - 容器 v1 工作的Azure Functions

使用 Docker 容器更新函式應用程式。

使用 Docker 容器更新函式應用程式。

Syntax

# 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 Resource Manager訂用帳戶。


appName - 應用程式名稱
string. 必要。

適用于容器的函式應用程式名稱。


deployToSlotOrASE - 部署至位置或App Service 環境
boolean. 預設值:false

將此輸入設定為 true ,以部署到現有的部署位置或Azure App 服務環境。 此工作需要這兩個目標的資源組名。 針對部署位置選項,預設會部署到 生產 位置,或者您可以指定任何其他現有的位置名稱。 如果部署目標是Azure App 服務環境,請將位置名稱保留為生產環境,並指定資源組名。


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 Service的應用程式 URL。

備註

使用此工作,使用 自訂映射在 Linux 上部署 Azure 函式。

錯誤:無法擷取 Azure 的存取權杖。 確認所使用的服務主體是否有效且未過期。

此工作會使用服務連線中的服務主體向 Azure 進行驗證。 如果服務主體已過期或沒有App Service的許可權,工作就會失敗,並出現此錯誤。 請確認使用的服務主體是否有效,以及是否存在於應用程式註冊中。 如需詳細資訊,請參閱使用角色型存取控制來管理 Azure 訂用帳戶資源的存取此部落格文章 也包含使用服務主體驗證的詳細資訊。

SSL 錯誤

如果您想要在 App Service 中使用憑證,則必須由受信任的憑證授權單位單位簽署憑證。 如果您的 web 應用程式出現憑證驗證錯誤,您可能使用了自我簽署憑證。 將名為 VSTS_ARM_REST_IGNORE_SSL_ERRORS 的變數設定為組建或發行管線中的值 true ,以解決錯誤。

發行長時間停止回應,然後失敗

此問題可能是您的App Service方案中容量不足的結果。 若要解決此問題,您可以相應增加 App Service 實例,以提高可用的 CPU、RAM 和磁碟空間,或嘗試使用不同的App Service方案。

5xx 錯誤碼

如果您看到 5xx 錯誤, 請檢查 Azure 服務的狀態

Azure 函式突然停止運作

如果自上次部署以來超過一年,Azure Functions可能會突然停止運作。 如果您在 「deploymentMethod」 中使用 「RunFromPackage」 進行部署,就會產生到期日為 1 年的 SAS,並在應用程式組態中設定為 「WEBSITE_RUN_FROM_PACKAGE」。 Azure Functions使用此 SAS 參考封裝檔案來執行函式,因此如果 SAS 已過期,則不會執行函式。 若要解決此問題,請再次部署以產生一年到期日的 SAS。

如何設定我的服務連線?

此工作需要Azure Resource Manager服務連線

如何使用 Application Insights 設定 Web 作業部署?

當您部署至App Service時,如果您已設定Application Insights且已啟用 Remove additional files at destination ,則也需要啟用 Exclude files from the App_Data folder 。 啟用此選項可讓 Application Insights 延伸模組保持安全狀態。 這是必要步驟,因為 Application Insights 連續 WebJob 會安裝到 App_Data 資料夾中。

當我部署至 App Service 時,應該如何設定代理程式位於 Proxy 後方?

如果您的自我裝載代理程式需要 Web Proxy,您可以在設定期間通知代理程式有關 Proxy。 這樣做可讓您的代理程式透過 Proxy 連線到 Azure Pipelines 或Azure DevOps Server。 深入瞭解在 Web Proxy 後方執行自我裝載代理程式

範例

此範例會使用容器在 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
要求
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任意
Settable 變數 任意
代理程式版本 2.104.1 或更新版本
工作類別 部署