Bicep 部署错误:读取文件时发生错误。找不到路径“/home/vsts/work/1/s/bicep/storageaccount.bicep”的一部分
我正在尝试在 devOps yml 管道中使用 powershell 任务部署二头肌模板。
我有以下任务:
- task: AzurePowerShell@4
displayName: "4.3) Deploy xxxxxx Synapse Infra"
enabled: true
inputs:
azureSubscription: ${{parameters.azureServiceConnection}}
ScriptType: "InlineScript"
azurePowerShellVersion: "LatestVersion"
continueOnError: true
errorActionPreference : "continue"
Inline: |
echo "Deploy Bicep template"
$deployment = New-AzResourceGroupDeployment `
-ResourceGroupName "rg-emdi-data-${{parameters.environment}}" `
-TemplateFile "$env:BUILD_SOURCESDIRECTORY\bicep\storageaccount.bicep" `
-envName "${{parameters.environment}}" `
-location "${{parameters.location}}" `
-storageId "$(storageID)" `
但是,当我运行它时,我收到以下错误消息:
ERROR: An error occurred reading file. Could not find a part of the path '/home/vsts/work/1/s/bicep/storageaccount.bicep'.
如果我部署 main.bicep 它可以工作,但在部署存储帐户模块时会失败。 任何帮助都会很棒。
I'm trying to deploy a bicep template using a powershell task in a devOps yml pipeline.
I have the following task:
- task: AzurePowerShell@4
displayName: "4.3) Deploy xxxxxx Synapse Infra"
enabled: true
inputs:
azureSubscription: ${{parameters.azureServiceConnection}}
ScriptType: "InlineScript"
azurePowerShellVersion: "LatestVersion"
continueOnError: true
errorActionPreference : "continue"
Inline: |
echo "Deploy Bicep template"
$deployment = New-AzResourceGroupDeployment `
-ResourceGroupName "rg-emdi-data-${{parameters.environment}}" `
-TemplateFile "$env:BUILD_SOURCESDIRECTORY\bicep\storageaccount.bicep" `
-envName "${{parameters.environment}}" `
-location "${{parameters.location}}" `
-storageId "$(storageID)" `
However, when I run it, I get the following error message :
ERROR: An error occurred reading file. Could not find a part of the path '/home/vsts/work/1/s/bicep/storageaccount.bicep'.
I can't understand why the file path is not resolved. My file structure is:
It works if I deploy main.bicep but fails when deploying the storage account module.
Any help would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
部署作业不会自动克隆源存储库,因此您可以使用 Thomas 提到的工件方法,也可以添加
checkout: self
步骤。来自文档:部署作业
在 YAML 管道中,这看起来像这样:
A deployment job does not automatically clone the source repo, so you can either use the artifact approach as mentioned by Thomas or you can add a
checkout: self
step.From the documentation: Deployment Jobs
This would look like something like this inside the YAML pipeline: