Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to reference connection status of connection resource in condition #14002

Open
marshalexander99 opened this issue May 3, 2024 · 1 comment

Comments

@marshalexander99
Copy link

Bicep version
0.26.170

Describe the bug
I only want to deploy a series of VM's if a previously deployed VPN connection status is "Connected" however I'm getting the following error:
The expression cannot be evaluated, because the identifier properties of the referenced existing resource including "name" cannot be calculated at the start of the deployment. In this situation, the accessible properties of "dccon" include "apiVersion", "id", "name", "type".bicep(BCP307).

To Reproduce
Try and reference the connection status property for an existing connection resource and use it in an if condition.

@ahelland
Copy link

ahelland commented May 3, 2024

It might not be obvious from the error message, but it's saying that a status property like "connected" cannot be checked at compile time. And if it cannot be checked compile time it cannot be used for conditionals.

While I haven't tested your specific use case (so disclaimer about it actually working) I'm guessing you might be able to workaround like this:

  • Add a "deployVMs" bool as a param in the VM Bicep.
  • Run a deployment script with a PowerShell/Azure CLI script to check status of VPN.
  • Parse output and run a deployment of the VM Bicep with with a true or false accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants