VSTS Pipeline Deployment of ARM Error: Could not find any file matching the template file pattern
Asked Answered
B

6

11

I am trying to deploy an Azure ARM script in VSTS Pipeline.

I "Published" the Artifacts in the Build Step and Downloaded the Artifacts in the Release Step. The Log seems to indicate that it found the ARM script (After much trial and error. The prescribed manner found here does not seem to work at all).

I however get Error: Could not find any file matching the template file pattern

Incidentally, I get this error even if can't find the file (which makes sense..but not when it actually does find the file). The ARM script deploys correctly when I deploy manually in Azure Portal.

I am using the Azure Resource Group Deployment step in the release pipeline.

I'm not sure what other information might help troubleshoot this, but request and hopefully I can get it to you.

Thanks

2018-12-14T18:32:06.6009951Z ##[section]Starting: Azure Deployment:Create Or Update Resource Group action on ChrisGroup
2018-12-14T18:32:06.6015952Z 

==============================================================================
2018-12-14T18:32:06.6016124Z Task         : Azure Resource Group 
Deployment
2018-12-14T18:32:06.6016287Z Description  : Deploy an Azure resource manager (ARM) template to a resource group. You can also start, stop, delete, deallocate all Virtual Machines (VM) in a resource group
2018-12-14T18:32:06.6016444Z Version      : 2.141.4
2018-12-14T18:32:06.6016526Z Author       : Microsoft Corporation
2018-12-14T18:32:06.6016655Z Help         : [More Information] (https://aka.ms/argtaskreadme)
2018-12-14T18:32:06.6016801Z 
==============================================================================
2018-12-14T18:32:06.9610677Z Checking if the following resource group exists: ChrisGroup.
2018-12-14T18:32:07.2734470Z Resource group exists: true.
2018-12-14T18:32:07.2736899Z Creating deployment parameters.
2018-12-14T18:32:07.2809876Z The detected encoding for file 'D:\a\r1\a\IAC\ARM.json' is 'utf-8'
2018-12-14T18:32:07.3021166Z ##[error]Error: Could not find any file matching the template file pattern
2018-12-14T18:32:07.3030720Z ##[section]Finishing: Azure Deployment:Create Or Update Resource Group action on ChrisGroup

As per request:

In the Template Parameters field I put -dailyreports_name '$(IACWeb)' -dailyreportsapi_name '$(IACAPI)'

and OMG... It's supposed to be a path to a variables file. UGH

Once I put into the Override Template Parameters, it works.

Microsoft should probable reword the label to "Template Parameters File"

Bifid answered 14/12, 2018 at 19:10 Comment(3)
What values are you providing to the step?Nanaam
Thanks for the jog to the brain. I completely didn't expect it to be anything other than the path to the template file. The error message was quite misleading.Bifid
My problem was CaSe SeNsItiViTy. Check. Now check again, If it's after midnight go to bed and try again tomorrow.Songer
B
13

You need to put the parameters being passed in into the "Override template parameters". The "Template parameters" field is actually a reference to a file location.

Bifid answered 17/12, 2018 at 14:22 Comment(2)
I am currently running into the same issue as you are, but I am not able to resolve it. It used to work, but I added some .sql files to my application and now it suddenly throws the error "could not find any files", what exactly do you mean by "override template parameters"Dissolve
It's one of the fields in the Azure Resource Group Deployment task.Fielding
D
1

When migrating from Classic to YAML deployments:

Seeing:

##[error]Error: Could not find any file matching the template file pattern,

may be because you're referencing Pipeline Artifacts through the inputs csmFile and csmParametersFile, without actually having access to them in your pipelines stage. You may need to download the artifacts first, as seen in the second stage in this answer.

A quick check to see if this is the case would be to by-pass your artifacts, and point the mentioned inputs directly to your azuredeploy.json and azuredeploy.parameters.json files where they are located in your repo.

Debidebilitate answered 6/10, 2022 at 15:16 Comment(0)
M
0

##[error]Error: Could not find any file matching the template file pattern

Check few things here :

  1. check all parameter names (case sensitive) in the parameter file and template file.

  2. if you are using yml file for azure devops pipeline,

    check all overrideParameters are correctly mentioned overrideParameters: '-environment "${{parameters.environment}}"' #for example

    check csmParametersFile , csmFile path in the yml

Mellisa answered 10/12, 2020 at 4:29 Comment(0)
S
0

For me, the issue turned out to be that I had to select specific build number while creating the release. If don't use specific build and just leave latest version option by default, then this error comes.

Septarium answered 2/4, 2021 at 13:28 Comment(0)
B
0

Make sure all your variables are defined and correct!

None of the previous answers helped me substantially. In my case it was because here:

- csmFile: '$(Build.SourcesDirectory)/$(template_file_location)'

I forgot to actually create the template_file_location variable. Once I created it in the Azure DevOps pipeline library and set it to the right path (Deployment/Infrastructure/infrastructure.json in my case) it worked perfectly.

Unfortunately the Azure Pipelines error logging is not very satisfying, even if you enable the system diagnostics.

Benioff answered 30/1 at 11:28 Comment(0)
S
0

I had this problem. I thought the issue was that csmParametersFile is required. It isn't

The probem was I was I needed a

- checkout: self

As I was deploying from

csmFile: '$(Build.Repository.LocalPath)\src\template.json'

But in a deployment stage, files aren't automatically downloaded (you'd normally download an artifact)

Songer answered 15/7 at 6:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.