Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 1.29 KB

linter-rule-no-unused-existing-resources.md

File metadata and controls

37 lines (24 loc) · 1.29 KB
title description ms.topic ms.custom ms.date
Linter rule - no unused existing resources
Linter rule - no unused existing resources
reference
devx-track-bicep
03/20/2024

Linter rule - no unused existing resources

This rule finds existing resources that aren't referenced anywhere in the Bicep file.

Linter rule code

Use the following value in the Bicep configuration file to customize rule settings:

no-unused-existing-resources

Solution

To reduce confusion in your template, delete any existing resources that are defined but not used. This test finds any existing resource that isn't used anywhere in the template.

The following example fails this test because the existing resource stg is declared but never used:

resource stg 'Microsoft.Storage/storageAccounts@2022-09-01' existing = {
  name: 'examplestorage'
}

Use Quick Fix to remove the unused existing resource.

:::image type="content" source="./media/linter-rule-no-unused-existing-resources/linter-rule-no-unused-existing-resources-quick-fix.png" alt-text="The screenshot of No unused existing resources linter rule quick fix.":::

Next steps

For more information about the linter, see Use Bicep linter.