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

Building Arm Template with Bicep, types:Microsoft.Insights/diagnosticSettings not being recognized. #9247

Closed
jrspinella opened this issue Dec 9, 2022 · 7 comments
Labels
Needs: Author Feedback Awaiting feedback from the author of the issue

Comments

@jrspinella
Copy link

jrspinella commented Dec 9, 2022

Bicep version
v0.13.1

AZCLI version
v2.43.0

Describe the bug
When using the Build command for Subscription level deployments. Types: Microsoft.Insights/diagnosticSettings not being recognized.

Using Schema "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#"

This may be an ARM Template Tool problem not sure.

Errors from Deployments:

{
  "code": "DeploymentFailed",
  "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",
  "details": [
    {
      "code": "InvalidTemplate",
      "message": "Deployment template parse failed: 'Required property 'type' not found in JSON. Path ''.'."
    }
  ]
} 

To Reproduce
Steps to reproduce the behavior:
Right click on Build ARM Template
View new deploy.json

Additional context
image

image

@ghost ghost added the Needs: Triage 🔍 label Dec 9, 2022
@alex-frankel
Copy link
Collaborator

I don't think the warning you grabbed a screenshot of is related to the error. Can you share both the complete bicep file(s) and generated ARM template?

@jrspinella
Copy link
Author

I don't think the warning you grabbed a screenshot of is related to the error. Can you share both the complete bicep file(s) and generated ARM template?

The bicep is a parent module to child modules.
deploy.bicep.txt
deploy.json.txt

This is one of the modules that is crashing on
az.data.storage.bicep.txt

Every module has this fails:

resource storageAccount_diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = if ((!empty(diagnosticStorageAccountId)) || (!empty(diagnosticWorkspaceId)) || (!empty(diagnosticEventHubAuthorizationRuleId)) || (!empty(diagnosticEventHubName))) { name: diagnosticSettingsName properties: { storageAccountId: !empty(diagnosticStorageAccountId) ? diagnosticStorageAccountId : null workspaceId: !empty(diagnosticWorkspaceId) ? diagnosticWorkspaceId : null eventHubAuthorizationRuleId: !empty(diagnosticEventHubAuthorizationRuleId) ? diagnosticEventHubAuthorizationRuleId : null eventHubName: !empty(diagnosticEventHubName) ? diagnosticEventHubName : null metrics: diagnosticsMetrics } scope: storageAccount }

@jrspinella
Copy link
Author

This is not a isolated issue.

Azure/azure-resource-manager-schemas#2708

@MercyMarkus
Copy link

Update:

I still have a warning regarding the type not being recognized (Microsoft.Insights/diagnosticSettings) in the .json ARM template I created through clicking on "Build ARM Template" in VS Code.

What's Changed:

  • I've been able to deploy this ARM template successfully despite this warning.

What I did:

  • I deployed my original bicep template to Azure using the az deployment group create command and inspected the generated ARM deployment template that was used by Azure.

How to do this:

  1. In Azure, go to the resource group your bicep template's resources were deployed into.
  2. In the left menu bar, under the "settings" subheading, click on "deployments".
  3. Click on the deployment name ---> click on "templates" in the left menu bar.
  4. Inspect the template.

On inspecting the template, I saw that Azure is using the exact same schema version and diagnostics settings variable that VS Code is flagging as a warning. I decided to try deploying the ARM template with the warning attached again and it worked.

Chances are I had some other errors I've resolved since my comment on Friday, so you might want to look into this as well.

Additional thing I did

I don't know if this helped but I deleted the metadata that gets appended to the top of the ARM template file when it's created in VS Code.
i.e

  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.13.1.58284",
      "templateHash": "16232601833143606848"
    }
  },

@alex-frankel
Copy link
Collaborator

@jrspinella -- the code you shared is not complete enough to reproduce the issue. Both files have lots of module references that cannot be resolved because they were not shared. Are you able to share a complete, deployable sample that reproduces the issue?

I'm 99% sure the root cause for the failed deployment is not the warning you are seeing. As @MercyMarkus experienced, it is likely a red herring. The warning is because the ARM Tools extension is missing info in the schema file it uses, but that, in and of itself, would not cause a deployment failure.

@jrspinella
Copy link
Author

Hi,

I am using Azure NoOps Accelerator. You can use the repo that I am using http://aka.ms/azurenoops. Follow the instructions for the quickstart on the readme.

@jrspinella
Copy link
Author

This has been fixed. https://github.com/Azure/NoOpsAccelerator/issues/226

@ghost ghost locked as resolved and limited conversation to collaborators May 24, 2023
@StephenWeatherford StephenWeatherford added Needs: Author Feedback Awaiting feedback from the author of the issue and removed awaiting response labels Oct 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Author Feedback Awaiting feedback from the author of the issue
Projects
None yet
Development

No branches or pull requests

4 participants