【发布时间】:2021-01-09 00:01:46
【问题描述】:
我在发布管道中使用 PowerShell 内联任务将相应的 zip 文件部署到 Azure 应用服务,但由于以下错误,我无法实现它。如果我在这里缺少任何东西,请告诉我。
我遇到了错误
Invoke-RestMethod:路径 'D:\a\r1\a_CI-VI-Maven/DeployPackages/marnet.zip' 解析为一个目录。指定包含文件名的路径,然后重试该命令。
下面是我使用的脚本:
$username = "用户名"
$password = "密码"
$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"
【问题讨论】:
-
在本地它就像一个魅力。我也尝试使用 PUT 方法,但仍然存在相同的结果。后来我尝试创建一个示例项目并执行相同的过程,没有代码更改,它按预期工作。我还在解决这个问题。
-
在下面查看我的答案,您应该更正脚本中
$filepath的值,marnet.zip是文件夹名称而不是压缩文件,可能真正的文件路径是path/marnet.zip/xx.zip。更正路径,您的问题就会消失。
标签: powershell azure-devops azure-pipelines-release-pipeline kudu