You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/linter-rule-use-resource-id-functions.md
+76-58Lines changed: 76 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,23 @@
2
2
title: Linter rule - use resourceId functions
3
3
description: Linter rule - use resourceId functions
4
4
ms.topic: conceptual
5
-
ms.date: 09/21/2022
5
+
ms.date: 09/23/2022
6
6
---
7
7
8
8
# Linter rule - use resourceId function
9
9
10
-
This rule finds uses of Azure location values that aren't parameterized.
10
+
Ensures that the ID of a symbolic resource name or a suitable function is used rather than a manually-created ID, such as a concatenating string, for all properties representing a resource ID. Use resource symbolic names whenever it is possible.
11
11
12
-
If property "id" represents a resource ID, it must use a symbolic resource reference, be a parameter or start with one of these functions: extensionResourceId, guid, if, reference, resourceId, subscription, subscriptionResourceId, tenantResourceId. Found nonconforming expression at id -> serviceBusConnectionId [https://aka.ms/bicep/linter/use-resource-id-functions]
@@ -19,75 +28,84 @@ Use the following value in the [Bicep configuration file](bicep-config-linter.md
19
28
20
29
## Solution
21
30
22
-
Template users may have limited access to regions where they can create resources. A hard-coded resource location might block users from creating a resource, thus preventing them from using the template. By providing a location parameter that defaults to the resource group location, users can use the default value when convenient but also specify a different location.
23
-
24
-
Rather than using a hard-coded string or variable value, use a parameter, the string 'global', or an expression (but not `resourceGroup().location` or `deployment().location`, see [no-loc-expr-outside-params](./linter-rule-no-loc-expr-outside-params.md)). Best practice suggests that to set your resources' locations, your template should have a string parameter named `location`. This parameter may default to the resource group or deployment location (`resourceGroup().location` or `deployment().location`).
25
-
26
-
The following example fails this test because the resource's `location` property uses a string literal:
31
+
The following example fails this test because the resource's `api/id` property uses a manually-created string:
You can fix it by creating a new `location` string parameter (which may optionally have a default value - resourceGroup().location is frequently used as a default):
description: 'Use this connector to query your Azure Monitor Logs across Log Analytics workspace and Application Insights component, to list or visualize results.'
The following example fails this test because a string literal is being passed in to a module parameter that is in turn used for a resource's `location` property:
description: 'Use this connector to query your Azure Monitor Logs across Log Analytics workspace and Application Insights component, to list or visualize results.'
0 commit comments