本文介绍了无法使用Kudu api将.zip文件部署到Azure App Service的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在发布管道中使用PowerShell内联任务将各自的zip文件部署到Azure App Service,但是由于以下错误,我无法实现它.您能否让我知道这里是否缺少任何东西.

I'm using PowerShell inline task in the release pipeline to deploy the respective zip file to the Azure App Service, but im unable to achieve it due to the below error. Can you please let me know if there is any thing that im missing here.

我遇到错误了
Invoke-RestMethod:路径"D:\ a \ r1 \ a_CI-VI-Maven/DeployPackages/marnet.zip"解析为目录.指定包含文件名的路径,然后重试该命令.

I'm getting below error
Invoke-RestMethod : Path 'D:\a\r1\a_CI-VI-Maven/DeployPackages/marnet.zip' resolves to a directory. Specify a path including a file name, and then retry the command.

以下是我正在使用的脚本:

$ username ="用户名"
$ password ="pwd"

$username = "username"
$password = "pwd"

$ base64AuthInfo = [Convert] :: ToBase64String([Text.Encoding] :: ASCII.GetBytes(("{0}:{1}" -f $ username,$ password)))$ userAgent ="powershell/1.0"

$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))$userAgent = "powershell/1.0"

$ apiUrl ="https://{appservice} .scm.azurewebsites.net/api/zip/site/wwwroot/webapps/"
$ filePath ="$(System.DefaultWorkingDirectory)_CI-VI-Maven/DeployPackages/marnet.zip"

Invoke-RestMethod -Uri $ apiUrl -Headers @ {Authorization =("Basic {0}" -f $ base64AuthInfo)} -UserAgent $ userAgent -Method POST -InFile $ filePath -ContentType"multipart/form-data"

$apiUrl = "https://{appservice}.scm.azurewebsites.net/api/zip/site/wwwroot/webapps/"
$filePath = "$(System.DefaultWorkingDirectory)_CI-VI-Maven/DeployPackages/marnet.zip"

Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -UserAgent $userAgent -Method POST -InFile $filePath -ContentType "multipart/form-data"

推荐答案

检查您的文件夹结构,看来您有一个名为 marnet.zip 的文件夹!

Check your folder structure, it seems that you have a folder named marnet.zip!

由于 $ filePath ="$(System.DefaultWorkingDirectory)_CI-VI-Maven/DeployPackages/marnet.zip" 是文件夹 marnet.zip 而不是实际的 marnet.zip 文件.

我的可重复步骤:

1.当我的 s.zip 文件直接位于构建工件文件夹下时,一切正常.

1.Everything works well when my s.zip file locates directly under build artifacts folder.

2.更改Build管道中的内容以创建 s.zip 文件夹,并将 s.zip 文件移动到该文件夹​​.

2.Change something in Build pipeline to create s.zip folder, and move the s.zip file to this folder.

3.然后,出现相同的问题:

3.Then, same issue occurs:

这篇关于无法使用Kudu api将.zip文件部署到Azure App Service的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 22:29