简体   繁体   中英

Getting error when deploying WebJob to Azure?

Im deploying a webjob to Azure App using the kudu zip push deployment for a web app in Powershell

I am using the following:

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 ?

If i check Azure it says that the webjob is "Pending Restart" and it doesnt get out of that state?

In order to publish the Zip deployment in KUDU you need to use credentials of web app publish profile file.在此处输入图像描述

and Kudu has a set of rest Api to perform crud operations. Here is the github link to know more about the Kudu rest apis:

You can use the below set of code to perform the zip deployment:

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" 

In general for any changes in configuration or updates, web app request you to perform a restart operation to apply those changes. As you mentioned in the error message webjob returned a status code "202"(Accepted) Since the webjob does not received any confirmation about the previous operation got succeeded or not, that is the reason why your webjob status is showing as " pending restart ".

I would suggest you to stop and start the webjob manually and try performing the deployment operation again.

For me RestMethod does not work.

$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

But the WebRequest:

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

Also create a test webjob from the portal to check your valid uri. For me was really different than default ones in manuals.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM