다음을 통해 공유


빠른 시작: Bicep을 사용하여 Azure App Configuration 저장소 만들기

이 빠른 시작에서는 Bicep을 사용하여 다음을 수행하는 방법에 대해 설명합니다.

  • App Configuration 저장소를 배포합니다.
  • App Configuration 저장소에서 키-값을 만듭니다.
  • App Configuration 저장소에서 키-값을 읽습니다.

Bicep은 선언적 구문을 사용하여 Azure 리소스를 배포하는 DSL(도메인 특정 언어)입니다. 간결한 구문, 신뢰할 수 있는 형식 안전성 및 코드 다시 사용에 대한 지원을 제공합니다. Bicep은 Azure에서 코드형 인프라 솔루션에 대한 최고의 제작 환경을 제공합니다.

필수 조건

Azure 구독이 없는 경우 시작하기 전에 체험 계정을 만듭니다.

권한 부여

Bicep 파일을 사용하여 Azure App Configuration 리소스를 관리하려면 기여자 또는 소유자와 같은 Azure Resource Manager 역할이 필요합니다. Azure App Configuration 데이터(키-값, 스냅샷)에 액세스하려면 구성 저장소의 ARM 인증 모드가 통과 ARM 인증 모드로 설정된 Azure Resource Manager 역할 및 추가 Azure App Configuration 데이터 창 역할이 필요합니다.

Important

ARM 인증 모드를 구성하려면 App Configuration 컨트롤 플레인 API 버전 2023-08-01-preview 이상이 필요합니다.

Bicep 파일 검토

이 빠른 시작에서 사용되는 Bicep 파일은 Azure 빠른 시작 템플릿에서 나온 것입니다.

참고 항목

Bicep 파일은 ARM 템플릿과 동일한 기본 엔진을 사용합니다. ARM 템플릿 빠른 시작에 있는 모든 팁, 참고 및 중요한 정보가 여기에 적용됩니다. Bicep 파일로 작업할 때 이 정보를 참조하는 것이 좋습니다.

@description('Specifies the name of the App Configuration store.')
param configStoreName string

@description('Specifies the Azure location where the app configuration store should be created.')
param location string = resourceGroup().location

@description('Specifies the names of the key-value resources. The name is a combination of key and label with $ as delimiter. The label is optional.')
param keyValueNames array = [
  'myKey'
  'myKey$myLabel'
]

@description('Specifies the values of the key-value resources. It\'s optional')
param keyValueValues array = [
  'Key-value without label'
  'Key-value with label'
]

@description('Specifies the content type of the key-value resources. For feature flag, the value should be application/vnd.microsoft.appconfig.ff+json;charset=utf-8. For Key Value reference, the value should be application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8. Otherwise, it\'s optional.')
param contentType string = 'the-content-type'

@description('Adds tags for the key-value resources. It\'s optional')
param tags object = {
  tag1: 'tag-value-1'
  tag2: 'tag-value-2'
}

resource configStore 'Microsoft.AppConfiguration/configurationStores@2021-10-01-preview' = {
  name: configStoreName
  location: location
  sku: {
    name: 'standard'
  }
}

resource configStoreKeyValue 'Microsoft.AppConfiguration/configurationStores/keyValues@2021-10-01-preview' = [for (item, i) in keyValueNames: {
  parent: configStore
  name: item
  properties: {
    value: keyValueValues[i]
    contentType: contentType
    tags: tags
  }
}]

output reference_key_value_value string = configStoreKeyValue[0].properties.value
output reference_key_value_object object = {
  name: configStoreKeyValue[1].name
  properties: configStoreKeyValue[1].properties
}

Bicep 파일에는 두 개의 Azure 리소스가 정의되어 있습니다.

이 Bicep 파일을 사용하여 두 개의 서로 다른 값이 있는 하나의 키를 만듭니다. 그 중 하나에는 고유한 레이블이 있습니다.

Bicep 파일 배포

  1. Bicep 파일을 main.bicep으로 로컬 컴퓨터에 저장합니다.

  2. Azure CLI 또는 Azure PowerShell을 사용하여 Bicep 파일을 배포합니다.

    az group create --name exampleRG --location eastus
    az deployment group create --resource-group exampleRG --template-file main.bicep --parameters configStoreName=<store-name>
    

    참고 항목

    <store-name>을 App Configuration 저장소의 이름으로 바꿉니다.

    배포가 완료되면 배포에 성공했음을 나타내는 메시지가 표시됩니다.

배포된 리소스 검토

Azure CLI 또는 Azure PowerShell을 사용하여 리소스 그룹에 배포된 리소스를 나열합니다.

az resource list --resource-group exampleRG

Azure Portal을 사용하여 리소스를 나열할 수도 있습니다.

  1. Azure Portal에 로그인합니다.
  2. 검색 상자에서 App Configuration을 입력한 다음, 목록에서 App Configuration을 선택합니다.
  3. 새로 만든 App Configuration 리소스를 선택합니다.
  4. 작업 아래에서 구성 탐색기를 선택합니다.
  5. 두 개의 키-값이 있는지 확인합니다.

리소스 정리

더 이상 필요하지 않은 경우 Azure CLI 또는 Azure PowerShell을 사용하여 리소스 그룹 및 해당 리소스를 삭제합니다.

az group delete --name exampleRG

Azure Portal을 사용하여 리소스 그룹을 삭제할 수도 있습니다.

  1. 리소스 그룹으로 이동합니다.
  2. 리소스 그룹 삭제를 선택합니다.
  3. 탭이 표시됩니다. 리소스 그룹 이름을 입력하고, 삭제를 선택합니다.

다음 단계

기능 플래그 및 Key Vault 참조를 App Configuration 저장소에 추가하는 방법을 알아보기 위해 ARM 템플릿 예제를 확인합니다.