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

Strange issue with setting null on kind property #16385

Open
slavizh opened this issue Feb 12, 2025 · 1 comment
Open

Strange issue with setting null on kind property #16385

slavizh opened this issue Feb 12, 2025 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@slavizh
Copy link
Contributor

slavizh commented Feb 12, 2025

Bicep version
Bicep CLI version 0.33.93 (7a77c7f)

Describe the bug
I am experiencing this strange issue with Bicep template setting kind to null on a resource. To my understanding this is issue with Bicep instead of the resource.

To Reproduce
Steps to reproduce the behavior:

This template results in error:

param endpoint object = {
  name: 'ep0001'
  kind: null
}

resource endpointRes 'Microsoft.Insights/dataCollectionEndpoints@2023-03-11' = {
  name: endpoint.name
  location: resourceGroup().location
  kind: endpoint.kind
  properties: {
    networkAcls: {
      publicNetworkAccess: 'Enabled'
    }
    description: ''
  }
}
New-AzResourceGroupDeployment: 11:04:02 - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The template resource 'ep0001' at line '23' and column '9' is not valid: Evaluation result of language expression '[parameters('endpoint').kind]' is type 'Null', expected type is 'String'.. Please see https://aka.ms/arm-functions for usage details.'.
New-AzResourceGroupDeployment: The deployment validation failed

Slightly modified template but still setting kind to null results in success:

param endpoint object = {
  name: 'ep0001'
}

resource endpointRes 'Microsoft.Insights/dataCollectionEndpoints@2023-03-11' = {
  name: endpoint.name
  location: resourceGroup().location
  kind: null
  properties: {
    networkAcls: {
      publicNetworkAccess: 'Enabled'
    }
    description: ''
  }
}

Even if I put some condition the result is still error:

param endpoint object = {
  name: 'ep0001'
  kind: ''
}

resource endpointRes 'Microsoft.Insights/dataCollectionEndpoints@2023-03-11' = {
  name: endpoint.name
  location: resourceGroup().location
  kind: empty(endpoint.kind) ? null : endpoint.kind
  properties: {
    networkAcls: {
      publicNetworkAccess: 'Enabled'
    }
    description: ''
  }
}

Additional context
Add any other context about the problem here.

@slavizh
Copy link
Contributor Author

slavizh commented Feb 12, 2025

Same applies to Microsoft.Insights/dataCollectionRules resource.

@anthony-c-martin anthony-c-martin self-assigned this Feb 12, 2025
@anthony-c-martin anthony-c-martin added this to the v0.34 milestone Feb 12, 2025
@anthony-c-martin anthony-c-martin added bug Something isn't working and removed Needs: Triage 🔍 labels Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants