【问题标题】:I want to deploy or copy the artifacts to a subfolder inside the wwwroot of azure app service我想将工件部署或复制到 azure app 服务的 wwwroot 内的子文件夹
【发布时间】:2021-12-06 11:32:57
【问题描述】:

我正在使用 azure AzureWebApp@1 发布我的前端应用程序的内容,但是它必须部署到应用程序服务的 wwwroot 内的文件夹中。我尝试使用 customDeployFolder 但它不起作用。有没有办法可以使用 yaml 实现这一目标?谢谢

【问题讨论】:

  • 你在使用构建输出吗?你在使用基于 YMAL 的管道吗?
  • 我正在使用 yaml 基础管道

标签: azure-devops azure-web-app-service azure-webapps


【解决方案1】:

感谢@levi-lu-msft,您的回答很有帮助。

您可以使用 KUDU APIwwwroot 之外使用工件部署 azure 应用服务。您需要在 发布管道 中添加一个 azure PowerShell 任务并运行 kudu api。例如下面的脚本。

1、创建目录CustomDomain的脚本

    $WebApp = Get-AzWebApp -Name '<appname>' -ResourceGroupName '<resourcegroupname>'
    [xml]$publishingProfile = Get-AzWebAppPublishingProfile -WebApp $WebApp
    
    # Create Base64 authorization header
    $username = $publishingProfile.publishData.publishProfile[0].userName
    $password = $publishingProfile.publishData.publishProfile[0].userPWD
    $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
    $bodyToPOST = @{
        command = "md CustomDomain"
        dir = "D:\home\site"
    }
    
    # Splat all parameters together in $param
    $param = @{
        # command REST API url
        Uri = "https://<appname>.scm.azurewebsites.net/api/command"
        Headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}
        UserAgent = "powershell/1.0"
        Method = "POST"
        Body = (ConvertTo-Json $bodyToPOST)
        ContentType = "application/json"
    }
# Invoke REST call
Invoke-RestMethod @param

以上脚本将首先从您应用的发布配置文件中获取用户名和密码,稍后将用作调用 kudu api 的验证。 api 会运行你自定义的命令来创建目录 CustomDomain 在 "d:\home\site"

2、使用kudu api部署你的应用

CustomDomain 目录创建后,您可以调用 kudu api 将您的应用部署到 CustomDomain 目录。请参考下面的例子。

$param = @{  
            # zipdeploy api url  
            Uri = "https://<appname>.scm.azurewebsites.net/api/zip/site/CustomDomain"  
            Headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}  
            UserAgent = "powershell/1.0"  
            Method = "PUT"  
            # Deployment Artifact Path  
            InFile = "$(System.DefaultWorkingDirectory)\<artifacts_alias>\drop\<artifacts_name>.zip"  
            ContentType = "multipart/form-data"  
}  
# Invoke REST call  
Invoke-RestMethod @param  

InFile 值应指向发布管道下载的工件文件的位置。通常位于"$(System.DefaultWorkingDirectory)\&lt;artifacts_alias&gt;\drop\&lt;artifacts_name&gt;.zip"

参考here for more info

【讨论】:

    猜你喜欢
    • 2019-10-16
    • 1970-01-01
    • 2020-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-01
    • 1970-01-01
    • 2015-05-20
    相关资源
    最近更新 更多