【问题标题】:Getting error when deploying WebJob to Azure?将 WebJob 部署到 Azure 时出错?
【发布时间】:2021-11-09 06:04:55
【问题描述】:

我正在使用 kudu zip 推送部署为 Powershell 中的 Web 应用程序部署 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,它会说网络作业是“等待重新启动”并且它 没有摆脱那种状态?

【问题讨论】:

    标签: powershell azure-webjobs kudu


    【解决方案1】:

    为了在 KUDU 中发布 Zip 部署,您需要使用 Web 应用发布配置文件的凭据。

    而且 Kudu 有一套 rest Api 来执行 crud 操作。 这里是github link 了解更多关于 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,然后尝试再次执行部署操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-20
      • 2021-11-06
      • 1970-01-01
      相关资源
      最近更新 更多