Linter 규칙 - 안정적인 리소스 식별자 사용

리소스 이름은 비결정적 값을 사용하면 안 됩니다. 예를 들어 newGuid() 또는 utcNow()는 리소스 이름에 사용할 수 없거나 리소스 이름에 기본값에서 newGuid() 또는 utcNow()를 사용하는 매개 변수/변수를 포함할 수 없습니다.

Linter 규칙 코드

Bicep 구성 파일의 다음 값을 사용하여 규칙 설정을 사용자 지정합니다.

use-stable-resource-identifiers

솔루션

다음 예제에서는 리소스 이름에 utcNow()가 사용되므로 이 테스트에 실패합니다.

param location string = resourceGroup().location
param time string = utcNow()

resource sa 'Microsoft.Storage/storageAccounts@2023-04-01' = {
  name: 'store${toLower(time)}'
  location: location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
  properties: {
    accessTier: 'Hot'
  }
}

예제에서 utcNow() 함수를 제거하여 수정할 수 있습니다.

param location string = resourceGroup().location

resource sa 'Microsoft.Storage/storageAccounts@2023-04-01' = {
  name: 'store${uniqueString(resourceGroup().id)}'
  location: location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
  properties: {
    accessTier: 'Hot'
  }
}

다음 단계

Linter에 관한 자세한 내용은 Bicep Linter 사용을 참조하세요.