Azure / bicep-types-az

Bicep type definitions for ARM resources
MIT License
84 stars 27 forks source link

Microsoft.RecoveryServices/vaults@2024-04-01: "monitoringSettings parameter is invalid" error #2209

Open MarcoJanse opened 2 months ago

MarcoJanse commented 2 months ago

Bicep version Bicep CLI version 0.28.1 (ba1e9f8c1e)

Describe the bug When trying to deploy a Recovery Services Vault using Bicep and Microsoft.RecoveryServices/vaults@2024-04-01, the following error occurs:

monitoringSettings parameter is invalid. Please provide a valid monitoringSettings (Code: InvalidRestApiParameter)

Raw error:

{
  "code": "DeploymentFailed",
  "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.",
  "details": [
    {
      "code": "InvalidRestApiParameter",
      "message": "monitoringSettings parameter is invalid. Please provide a valid monitoringSettings"
    }
  ]

When using 'Microsoft.RecoveryServices/vaults@2024-01-01', it deploys without error. However, even if specifying monitoringSettings, the deployment still fails.

Using the following API versions all give the same error:

Versions from 2024-01-01 work fine.

To Reproduce Steps to reproduce the behavior:

Without monitoring settings

Use the following Bicep template to deploy a Recovery Services Vault without monitoring settings specified:

param location string = resourceGroup().location

param tags object = {
  Environment: 'Test'
}

resource RecoveryServicesVault  'Microsoft.RecoveryServices/vaults@2024-04-01' = {
  name: 'rsv-bicep-tst-001'
  location: location
  tags: tags
  sku: {
    name: 'RS0'
    tier: 'standard'
  }
  properties: {
    securitySettings: {
      softDeleteSettings: {
        softDeleteRetentionPeriodInDays: 14
        softDeleteState: 'Enabled'
        enhancedSecurityState: 'Enabled'
      }
    }
    redundancySettings: {
      standardTierStorageRedundancy: 'LocallyRedundant'
      crossRegionRestore: 'Disabled'
    }
    publicNetworkAccess: 'Enabled'
    restoreSettings: {
      crossSubscriptionRestoreSettings: {
        crossSubscriptionRestoreState: 'Disabled'
      }
    }
  }
}

With monitoring settings

Use the following Bicep template to deploy a Recovery Services Vault with monitoring settings:

param location string = resourceGroup().location

param tags object = {
  Environment: 'Test'
}

resource RecoveryServicesVault  'Microsoft.RecoveryServices/vaults@2024-04-01' = {
  name: 'rsv-bicep-tst-002'
  location: location
  tags: tags
  sku: {
    name: 'RS0'
    tier: 'standard'
  }
  properties: {
    securitySettings: {
      softDeleteSettings: {
        softDeleteRetentionPeriodInDays: 14
        softDeleteState: 'Enabled'
        enhancedSecurityState: 'Enabled'
      }
    }
    monitoringSettings: {
      azureMonitorAlertSettings: {
        alertsForAllJobFailures: 'Enabled'
      }
      classicAlertSettings: {
        alertsForCriticalOperations: 'Enabled'
      }
    }
    redundancySettings: {
      standardTierStorageRedundancy: 'LocallyRedundant'
      crossRegionRestore: 'Disabled'
    }
    publicNetworkAccess: 'Enabled'
    restoreSettings: {
      crossSubscriptionRestoreSettings: {
        crossSubscriptionRestoreState: 'Disabled'
      }
    }
  }
}

The documentation Microsoft.RecoveryServices vaults | Microsoft Learn does not have the latest API versions. The latest version in de documentation is 2023-01-01. So it's hard to see if I'm doing anything wrong, as the documentation is outdated.

CraigTolley commented 1 month ago

Hi @MarcoJanse,

I've just been working on this exact same issue and have found a way to get my deployment to work.

When specifying the monitoringSettings section, you must specify values for all 5 of the possible settings. As long as all 5 are present, the deployment succeeds.

This was my working deployment, using your template:

param location string = resourceGroup().location

param tags object = {
  Environment: 'Test'
}

resource RecoveryServicesVault  'Microsoft.RecoveryServices/vaults@2024-04-01' = {
  name: 'rsv-bicep-tst-002'
  location: location
  tags: tags
  sku: {
    name: 'RS0'
    tier: 'standard'
  }
  properties: {
    securitySettings: {
      softDeleteSettings: {
        softDeleteRetentionPeriodInDays: 14
        softDeleteState: 'Enabled'
        enhancedSecurityState: 'Enabled'
      }
    }
    monitoringSettings: {
      azureMonitorAlertSettings: {
        alertsForAllReplicationIssues: 'Enabled'
        alertsForAllFailoverIssues: 'Enabled'
        alertsForAllJobFailures: 'Enabled'
      }
      classicAlertSettings: {
        alertsForCriticalOperations: 'Disabled'
        emailNotificationsForSiteRecovery: 'Disabled'
      }
    redundancySettings: {
      standardTierStorageRedundancy: 'LocallyRedundant'
      crossRegionRestore: 'Disabled'
    }
    publicNetworkAccess: 'Enabled'
    restoreSettings: {
      crossSubscriptionRestoreSettings: {
        crossSubscriptionRestoreState: 'Disabled'
      }
    }
  }
}

Hope that helps, and hopefully this information can make its way into the documentation at some point, or preferably make it so that we can specify individual settings as required.

This is exactly the same behaviour with an ARM template as with bicep, so it is not a compilation issue.

MarcoJanse commented 4 weeks ago

Thank you for your providing this solution. Let's hope the documentation will soon be updated to reflect these properties are mandatory in order to successfully deploy.