簡體   English   中英

將 WebJob 部署到 Azure 時出錯?

[英]Getting error when deploying WebJob to Azure?

我使用 Powershell 中的 web 應用程序的 kudu zip 推送部署將 Web 作業部署到 Azure 應用程序

我正在使用以下內容:

az login -u <username>
az account set --subscription <subscription_name>
az webapp deployment source config-zip -g <ResourecGroup> -n <WebAppName> --src <pathetozipfile>

but i keep getting the error:

"az : Getting scm site credentials for zip deployment:
"Deployment endpoint responded with status code 202"

Am i missing a setting or parameter in the deploy ?

如果我檢查 Azure 它說 webjob 是“等待重新啟動”並且它沒有從 state 中退出?

為了在 KUDU 中發布 Zip 部署,您需要使用 web 應用程序發布配置文件的憑據。在此處輸入圖像描述

而Kudu有一組rest Api來進行crud操作。 這是github 鏈接以了解有關 Kudu rest api 的更多信息:

您可以使用下面的一組代碼來執行 zip 部署:

az login -u <username>
az account set --subscription <subscription_name>
$username = "`$website"
$password = "pwd"
 #Note that the $username here should look like `SomeUserName`, and **not** `SomeSite\SomeUserName`
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$userAgent = "powershell/1.0" ```


 #call the zipdeploy API (which uses POST)
 $apiUrl = "https://{sitename}.scm.azurewebsites.net/api/zipdeploy"
 $filePath = "C:\Temp\books.zip"
 Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method POST -InFile $filePath -ContentType "multipart/form-data" 

一般來說,對於配置或更新的任何更改,web 應用程序會要求您執行重啟操作以應用這些更改。 正如您在錯誤消息中提到的 webjob 返回狀態代碼“202”(已接受)由於 webjob 未收到有關先前操作是否成功的任何確認,這就是您的 webjob 狀態顯示為“等待重啟”的原因.

我建議您手動停止並啟動 webjob,然后再次嘗試執行部署操作。

對我來說,RestMethod 不起作用。

$response = Invoke-RestMethod `
    -Uri $uri `
    -ContentType "application/zip" `
    -Method "PUT" `
    -Headers @{ 
        Authorization         = $basic
        "Content-Disposition" = "attachment; filename=$($zippedArtifact.Name)"
    } `
    -UserAgent "PowerShell $($PSVersionTable.PSVersion.ToString())" `
    -InFile $artifact

但是網絡請求:

$response = Invoke-WebRequest -Uri $uri -Headers $headers -InFile $zippedArtifact -ContentType "application/zip" -Method Put

還可以從門戶創建一個測試 webjob 來檢查您的有效 uri。 對我來說,這與手冊中的默認設置確實不同。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM