question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validation for apiVersion should be able to look up variables

See original GitHub issue

It can be convenient to use a variable to set an apiVersion that is used in multiple places:

"variables": {
    "storageApiVersion": "2016-01-01"
}

...

"resources": [
  {
    "apiVersion": "[variables('storageApiVersion')]",
    "type": "Microsoft.Storage/storageAccounts",
    "name": "StorageAccountName",
    "location": "West US 2",
  } 
]

...

"diagnosticsStorageAccountConfig": {
  "blobEndpoint": "[reference(concat('Microsoft.Storage/storageAccounts/StorageAccountName/', variables('storageApiVersion')).primaryEndpoints.blob]",
}

It looks like the API version validation is not able to look up the value of the variable and therefore gives a validation error:

Value must be one of the following values: "2015-05-01-preview", "2015-06-15", "2016-01-01", "2017-06-01", "2017-10-01", "2018-02-01", "2018-11-01", "2019-04-01", "2019-06-01", "2018-03-01-preview", "2018-07-01"arm-template (schema)

The validation message contains the value “2016-01-01” indicating that it is indeed a valid value but does not recognize that this is the value of the variable referenced in the apiVersion element.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
StephenWeatherfordcommented, Feb 12, 2020

@snorrk Thanks. That is a feature that’s on our list, but is not prioritized yet. Can you verify that we’d only need to handle apiVersion strings with a simple variables(‘xxx’) or parameters(‘xxx’) expression and nothing else in it?

cc @neilpeterson

0reactions
StephenWeatherfordcommented, May 21, 2020

@alexgav This could be done in two ways…

  1. The lang server could interpret the expressions itself, looking up variables itself, although that could be problematic with nested templates which have different scope
  2. The lang server could send a request to the extension to interpret these expression values.

I’m leaning toward #2, what do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] apiVersion detection may be incorrect · Issue #3261
Try to create a "good" CronJob using v1 API version. See it's also blocked, and see that the variable in the message shows...
Read more >
Solved: Create ARM Deployment API Error for nested resourc...
Hi. I'm using Flow to Create an Azure ARM Deployment. I initialize two variables, one with the Template and one with the Parameters....
Read more >
5 - Stack Overflow
Wouldn't this say that it cannot find the resource named "resource not deployed" ?? If anything I would think you'd want an empty...
Read more >
Kubernetes Troubleshooting - Fixing Validation Error | Datree.io
When Kubernetes is unable to read and validate from the manifest, ... Unfortunately, you will end up with an `error validating data ...
Read more >
Validating Kubernetes YAML for best practice and policies
You can see all available helpers here. By default, it loads the entire input YAML file into the $$ variable and makes it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found