在Azure发布管道上使用部署脚本

时间:2019-05-30 19:19:37

标签: azure azure-devops

我已经成功创建并发布了版本,并将我的React应用程序部署在Azure Web App环境中。我创建的应用程序将部署在许多不同的客户环境中,并且我不想自己创建每个应用程序服务,因此我想使该过程自动化。我已经导出了模板,现在有一个deploy.psh1文件和一个parameters.json和一个template.json文件。但是我不确定现在该怎么办。

我尝试在发布步骤中添加powershell task,并在内联部分粘贴deploy.sh1的内容,但这会导致多个错误:

2019-05-30T19:16:31.9475172Z ##[section]Starting: PowerShell Script
2019-05-30T19:16:31.9534016Z ==============================================================================
2019-05-30T19:16:31.9534117Z Task         : PowerShell
2019-05-30T19:16:31.9534203Z Description  : Run a PowerShell script on Windows, macOS, or Linux.
2019-05-30T19:16:31.9534274Z Version      : 2.148.0
2019-05-30T19:16:31.9534351Z Author       : Microsoft Corporation
2019-05-30T19:16:31.9534429Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736)
2019-05-30T19:16:31.9534519Z ==============================================================================
2019-05-30T19:16:32.8910231Z Generating script.
2019-05-30T19:16:32.9442109Z ========================== Starting Command Output ===========================
2019-05-30T19:16:32.9667917Z ##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\agent\_work\_temp\c37bf4b5-41a1-4125-b7c3-04e0c77fe403.ps1'"
2019-05-30T19:16:33.2330921Z At C:\agent\_work\_temp\c37bf4b5-41a1-4125-b7c3-04e0c77fe403.ps1:30 char:10
2019-05-30T19:16:33.2331159Z +  [string]
2019-05-30T19:16:33.2331234Z +          ~
2019-05-30T19:16:33.2331512Z Missing closing ')' in expression.
2019-05-30T19:16:33.2332867Z At C:\agent\_work\_temp\c37bf4b5-41a1-4125-b7c3-04e0c77fe403.ps1:49 char:1
2019-05-30T19:16:33.2333119Z + )
2019-05-30T19:16:33.2333839Z + ~
2019-05-30T19:16:33.2334117Z Unexpected token ')' in expression or statement.
2019-05-30T19:16:33.2335145Z At C:\agent\_work\_temp\c37bf4b5-41a1-4125-b7c3-04e0c77fe403.ps1:29 char:2
2019-05-30T19:16:33.2335362Z +  [Parameter(Mandatory=$True)]
2019-05-30T19:16:33.2336143Z +  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-05-30T19:16:33.2336345Z Unexpected attribute 'Parameter'.
2019-05-30T19:16:33.2337371Z At C:\agent\_work\_temp\c37bf4b5-41a1-4125-b7c3-04e0c77fe403.ps1:40 char:2
2019-05-30T19:16:33.2337639Z +  [Parameter(Mandatory=$True)]
2019-05-30T19:16:33.2338286Z +  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-05-30T19:16:33.2338534Z Unexpected attribute 'Parameter'.
2019-05-30T19:16:33.2339929Z     + CategoryInfo          : ParserError: (:) [], ParseException
2019-05-30T19:16:33.2340251Z     + FullyQualifiedErrorId : MissingEndParenthesisInExpression
2019-05-30T19:16:33.2340819Z  
2019-05-30T19:16:33.3687310Z ##[error]PowerShell exited with code '1'.
2019-05-30T19:16:33.3968831Z ##[section]Finishing: PowerShell Script

所以我的问题是如何在发布期间添加app-service的创建?

1 个答案:

答案 0 :(得分:0)

有一个资源组部署任务,可直接用于部署ARM模板:https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment?view=azure-devops

它将您的parameter.json和template.json作为输入。

相关问题