Azure Resource Manager 템플릿 가져오기
이 안내에서는 작은 Azure Resource Manager 템플릿(Azure Verified Modules 모듈로 배포하는 Event Hubs 네임스페이스, 컨테이너를 실행하는 App Service 사이트, 정적 웹 앱, 그 사이트가 참여하도록 되어 있는 가상 네트워크)을 가져오고, 그 결과를 하나의 Azure Resource Manager 템플릿으로 빌드합니다. 가져오기는 Aggregate, Release, Manifest의 초안을 작성합니다. 네임스페이스와 사이트는 표준 라이브러리의 Components에 대한 참조가 되고, 어떤 Component도 해당하지 않는 정적 웹 앱은 템플릿에서 초안으로 작성되며, 템플릿이 Release가 받을 수 있는 형태로 명시한 값은 옮겨집니다. 그렇지 않은 몇몇 값은 작성자의 몫으로 남으며, 어떤 값이 어디에 있는지는 이 페이지가 보여 줍니다. 아래의 모든 파일과 모든 출력 블록은 실제 실행에서 나온 것입니다. 템플릿과 안내의 각 단계는 import-arm 예제에 있으며, 그곳의 검사 스크립트가 가져오기를 다시 실행하고, 그것이 쓰는 내용, 출력하는 내용, 이 페이지가 인용하는 블록을 그곳에 보관된 파일과 비교하며, 초안이 이 페이지가 말하는 곳에서 멈추는지 확인하고, 검토를 마친 Release를 빌드합니다.
예제 초안 작성하기
이 페이지의 명령으로 이 가져오기를 실행하거나, AI 어시스턴트가 대신 실행하게 할 수 있습니다.
예제 이름을 딴 새 폴더에 예제를 씁니다:
aggrega draft --example import-arm그런 다음 이어서 실행할 명령을 출력합니다. 첫 번째 명령은 새 폴더로 이동합니다. 그 뒤의 명령은 아래와 같으며, 새 폴더 안의 source 폴더로 이동합니다. 이 폴더에는 이 페이지가 가져오는 내용이 들어 있으며, 가져오기는 여기서 실행됩니다:
cd import-arm템플릿
main.json은 템플릿의 컴파일된 형태로, Bicep 빌드가 쓰는 JSON이며 Azure Resource Manager가 이를 배포합니다. 매개변수는 리전이고, 사이트가 참여하는 서브넷을 담은 가상 네트워크로 시작합니다:
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "location": { "type": "string", "defaultValue": "westeurope" } }, "resources": [ { "type": "Microsoft.Network/virtualNetworks", "apiVersion": "2023-11-01", "name": "vnet-notes", "location": "[parameters('location')]", "properties": { "addressSpace": { "addressPrefixes": [ "10.20.0.0/16" ] }, "subnets": [ { "name": "snet-app", "properties": { "addressPrefix": "10.20.1.0/24", "delegations": [ { "name": "web", "properties": { "serviceName": "Microsoft.Web/serverFarms" } } ] } } ] } },[… omitted: the rest of the template]네임스페이스는 Azure Verified Modules 모듈 avm/res/event-hub/namespace 0.15.3을 통해 배포됩니다. 이는 Microsoft.Resources/deployments 리소스로, template 멤버에는 모듈 자체의 컴파일된 템플릿(3,700줄이 넘습니다)이 들어 있고, parameters는 템플릿이 그 모듈에 설정하는 값입니다:
{ "type": "Microsoft.Resources/deployments", "apiVersion": "2022-09-01", "name": "ehModule", "properties": { "mode": "Incremental", "expressionEvaluationOptions": { "scope": "inner" }, "parameters": { "name": { "value": "evh-notes" }, "location": { "value": "[parameters('location')]" }, "skuName": { "value": "Standard" }, "skuCapacity": { "value": 2 }, "publicNetworkAccess": { "value": "Enabled" }, "enableTelemetry": { "value": true } }, "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",[… omitted: the module's compiled template, and the rest of the resource]모듈의 컴파일된 템플릿은 Microsoft Container Registry가 해당 버전으로 제공하는 것이며 MIT 라이선스입니다. 예제의 README에 고지문이 실려 있습니다. 가져오기는 모듈을 인식하기 위해 이를 읽습니다. 텔레메트리 접두사와 버전이 Azure Verified Modules 모듈과 그것이 배포하는 리소스 유형을 알려 줍니다.
사이트는 일반 리소스입니다. 이미 존재하는 App Service 플랜에서 실행되고, 템플릿의 서브넷에 참여하며, linuxFxVersion에 지정된 컨테이너를 실행하고, 모듈의 name 출력을 읽으며, 변수를 하나 더 설정합니다:
{ "type": "Microsoft.Web/sites", "apiVersion": "2023-12-01", "name": "notes-api", "location": "[parameters('location')]", "kind": "app,linux,container", "dependsOn": [ "[resourceId('Microsoft.Resources/deployments', 'ehModule')]", "[resourceId('Microsoft.Network/virtualNetworks', 'vnet-notes')]" ], "properties": { "serverFarmId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/notes-platform/providers/Microsoft.Web/serverfarms/plan-notes", "virtualNetworkSubnetId": "[resourceId('Microsoft.Network/virtualNetworks/subnets', 'vnet-notes', 'snet-app')]", "siteConfig": { "linuxFxVersion": "DOCKER|ghcr.io/example/notes-api:2.3.0", "appSettings": [ { "name": "EVENTHUB_NAMESPACE", "value": "[reference('ehModule').outputs.name.value]" }, { "name": "EVENTHUB_NAME", "value": "notes" } ] } } },정적 웹 앱도 일반 리소스입니다. 템플릿 옆의 매개변수 파일이 유일한 매개변수를 제공합니다:
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { "location": { "value": "northeurope" } }}두 파일은 notes 폴더에 있으며, 그 폴더 옆의 .aggrega-config.yaml이 이 디렉터리를 워크스페이스로 만들기 때문에 가져오기는 초안을 그곳에 씁니다.
# The workspace key marks this directory as the workspace root, so an import run# here writes its drafts beside the notes folder.workspace: {}# The registry the importer is fetched from the first time an import needs it.default_registry: hub.aggrega.ai가져오기는 템플릿과 그 매개변수 파일을 주석이 있는 JSON으로 읽으며, 템플릿은 $schema와 resources로, 매개변수 파일은 $schema와 parameters로 인식합니다. 각 리소스를 가져오기가 실행되는 방식에서 설명하는 대로 읽은 워크스페이스 카탈로그의 Components와 견주어 평가하며, 클라우드 계정은 읽지 않습니다. 템플릿이 배포되는 동안 계산하는 값은 그것을 계산하는 식 그대로 옮겨지며 조회되지 않습니다.
source로 이동합니다:
cd source가져오기 실행
템플릿이 들어 있는 폴더를 지정합니다. 임포터는 템플릿과 그 매개변수 파일을 내용으로 인식합니다.
aggrega import notes--target은 지정하지 않았습니다. 표준 라이브러리의 Azure Resource Manager용 Recipes가 그것에 바인딩되어 있으므로 임포터는 arm을 기본 대상으로 선언하고, 가져오기는 그에 대한 Manifest의 초안을 작성합니다. --target으로 대상을 지정한 가져오기는 대신 그 대상용으로 초안을 작성합니다. 가져오기가 초안 옆에 쓰는 기록에는 대상이 보관되며, --sync가 이를 다시 사용합니다.
표준 출력에는 작성한 것을 나열합니다:
wrote aggregate.yamlwrote release.yamlwrote manifest.yamlwrote catalog/component/imported/compute/microsoft-web-staticsites/0.1.0/component.yamlwrote catalog/recipe/arm/microsoft-web-staticsites/0.1.0/recipe.yamlwrote .aggrega-import.json표준 오류에는 다음과 같이 출력합니다. 여기서 <workspace>는 명령을 실행한 폴더를 나타냅니다:
[… omitted: a warning that the importer runs unverified, printed where its module is read from beside its Plugin entity in a catalog folder rather than fetched]read as the arm format, with drafted paths relative to <workspace>info: the drafts are for the target "arm", the importer's declared default; an import naming a target drafts for that oneinfo: ehmodule deploys the Azure Verified Modules resource module avm/res/event-hub/namespace, of telemetry prefix 46d3xbcp.res.962075c, version 0.15.3, named "Event Hub Namespaces" in its metadata: it is one node of the resource type Microsoft.EventHub/namespaces, the parameters it sets read as the module's, and the module's telemetry is not carried, as whether a Recipe sends telemetry is the Recipe's to setwarn: notes-api sets the variable EVENTHUB_NAMESPACE at properties.siteConfig.appSettings.0.value from ehmodule's outputs.name.value, and the drafted Aggregate does not wire it: ehmodule publishes no provides key for it; the instance notes-api is connected to ehmodule for the dependency alone, a comment above the connection saying why; write the value where the instance is configuredinfo: the resource notes-site of the type Microsoft.Web/staticSites@2023-01-01 is drafted from the source as the Component imported/compute/microsoft-web-staticsites and the Recipe microsoft-web-staticsites on arm, carrying the properties the source writes; the decision's swap hint names the import drafting it from the vendor's schemawarn: the source creates substrate the draft leaves to the operator and drafts nothing for: vnet-notes (Microsoft.Network/virtualNetworks), of which the format says the network a component runs in is the operator's: a component of the catalog takes it by its resource ID under infra.overrides, reading the parameter location at location; provide each where the Release deploys, and fill the pointers the Release leaves for themwarn: notes-api sets the variable EVENTHUB_NAME in the environment of the instance notes-api, and the draft delivers an instance's environment from its connections alone, so the variable is not carried: the instance's Release entry names it, for the author to set where the instance is configuredmapped ehmodule (Microsoft.EventHub/namespaces) to core/messaging/azure-event-hubs as a reference, HIGH at 0.8656mapped notes-site (Microsoft.Web/staticSites) to imported/compute/microsoft-web-staticsites as a draft, NONE at 0.05made no choice for vnet-notes (Microsoft.Network/virtualNetworks)mapped notes-api (Microsoft.Web/sites) to core/compute/server as a reference, HIGH at 0.9made no choice for resourceId('Microsoft.Network/virtualNetworks/subnets', 'vnet-notes', 'snet-app') ()[… omitted: what the pull could not render yet, a stop of the App Service Recipe's assertion that the Release names the subnet, which the sections below explain] external inputs: dependency pins were written and are complete; 0 external input(s) pinned, and any this Release also needs are still unpinned external inputs: a build of this Release halts naming the unpinned URL; fixing what stopped the render and resolving again pins itPull complete: <workspace>/release.lock (entities=8, source_artifacts=0, external_inputs=0)External inputs were not fully discovered: dependency pins are complete, external-input pins may not be (see the diagnostics above)info줄은 임포터가 묻지 않고 결정한 내용을 알려 줍니다. 첫 번째 줄은 초안이arm용이라고 알립니다. 두 번째 줄은 모듈을 인식합니다. 리소스ehmodule은 Event Hubs 네임스페이스의 Azure Verified Modules 모듈이며, 템플릿이 그것에 설정하는 매개변수가 모듈 자체의 것으로 읽히므로, 초안은 이를 읽어야 할 중첩 템플릿이 아니라 하나의 네임스페이스로 취급합니다. 세 번째 줄은 정적 웹 앱이 템플릿에서 초안으로 작성된다고 알립니다.warn줄은 초안이 옮기지 않는 내용을 알려 줍니다. 첫 번째 줄은 사이트가 모듈의name출력에서 읽는 변수입니다. 초안은 Component가 공개하는 것에 대해서만 연결을 배선하는데, 네임스페이스는 자신의 이름에 대한 키를 공개하지 않으므로 연결은 의존 관계만을 위해 존재합니다. 두 번째 줄은 템플릿이 만드는 가상 네트워크를 알리며, 초안이 맡기는 것에서 설명하듯 초안은 이를 작성자에게 맡깁니다. 세 번째 줄은 사이트가 설정하지만 초안의 어떤 연결도 전달하지 않는 변수를 알립니다.mapped줄은 각 리소스가 무엇이 되었는지를 알려 줍니다.ehmodule은 표준 라이브러리의core/messaging/azure-event-hubs의 인스턴스이고,notes-api는 범용 서버core/compute/server의 인스턴스입니다. 둘 다 높은 등급에서 일치했고 참조되었습니다.notes-site는 어떤 Component와도 일치하지 않으므로 일치 없는 초안입니다.made no choice줄은 초안이 아무것도 결정하지 않는 대상을 알려 줍니다. 가상 네트워크와, Release가 비워 두는 서브넷 포인터입니다.- 풀은
aggrega pull이 하는 것처럼, 초안으로 작성된 Release가 의존하는 것을 가져오기가 받아release.lock에 기록하는 일입니다. Manifest가 네임스페이스와 사이트에 지정하는 Recipes는 리소스를 직접 쓰고 아무것도 소스로 받지 않으므로source_artifacts는0이며, 풀은 카탈로그 밖으로 아무것도 가지러 가지 않습니다. 그런 다음 가져오기는 빌드가 받아 올 입력을 찾기 위해 Release를 렌더링해 보지만 App Service Recipe가 이를 멈춥니다. 초안에 아직 서브넷이 지정되어 있지 않기 때문입니다. 그래도 가져오기는 잠금 파일을 쓴 채로 끝나며, 외부 입력이 완전히 파악되지 않았다고 알립니다. 이 중단은 다음에 검증이 보고하는 것과 같습니다.
작성하는 내용
Aggregate, Release, Manifest의 이름은 imported/notes이며, 가져오기가 읽은 폴더의 이름을 따른 것입니다. 파일로 가져온 템플릿은 그 파일의 이름 main을 따라 이름이 붙습니다. 네임스페이스는 임포터의 target_namespace 설정이 정하며, 다른 값을 설정하지 않으면 imported입니다(설정).
aggregate.yaml — 리소스마다 항목 하나와, 사이트가 그리는 연결:
# Sources read: main.json, main.parameters.json.# Substrate the source creates, left to the operator: vnet-notes (Microsoft.Network/virtualNetworks).apiVersion: aggrega.ai/v1beta1kind: Aggregatemetadata: name: imported/notes version: 0.1.0 description: Draft Aggregate imported from a source in the arm format.spec: components: ehmodule: type: core/messaging/azure-event-hubs notes-site: type: imported/compute/microsoft-web-staticsites values: name: "notes-site" notes-api: type: core/compute/server uses: # Not wired: notes-api sets the variable EVENTHUB_NAMESPACE at properties.siteConfig.appSettings.0.value from ehmodule's outputs.name.value; ehmodule publishes no provides key for it. ehmodule: ehmodule: target: ehmodule정적 웹 앱은 가져오기가 초안으로 작성한 타입 imported/compute/microsoft-web-staticsites의 컴포넌트입니다. 사이트에서 네임스페이스로 가는 연결에는 inject 블록이 없습니다. 초안은 Component가 값을 공개할 때에만 연결에서 변수를 전달하기 때문이며, 그 위의 주석은 어떤 변수를 배선하지 않는지와 그 이유를 알려 줍니다.
release.yaml — 환경과 각 리소스의 설정:
apiVersion: aggrega.ai/v1beta1kind: Releasemetadata: name: imported/notes # environment is a drafted default, since no source names the environment this Release deploys to; change it to name the one it deploys to. environment: development version: 0.1.0 description: Draft Release imported from a source in the arm format.spec: aggregate: imported/notes manifest: imported/notes components: # Module parameters the source sets and the draft does not translate: location, name, publicNetworkAccess, skuCapacity, skuName. ehmodule: {} notes-site: infra: # From the template parameter location, the value the parameters file supplies. location: "northeurope" overrides: appLocation: "/" outputLocation: "dist" name: "Free" tier: "Free" # Properties the source writes and the draft does not place: kind, properties.siteConfig.linuxFxVersion. # Environment variables the source sets and no connection delivers: EVENTHUB_NAME = notes. notes-api: infra: overrides: service_plan_id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/notes-platform/providers/Microsoft.Web/serverfarms/plan-notes" # From the template parameter location, the value the parameters file supplies. location: "northeurope" # Left for the Release, since the source cannot supply it: infra.overrides.virtual_network_subnet_id, the pointer to the resource "resourceId('Microsoft.Network/virtualNetworks/subnets', 'vnet-notes', 'snet-app')", which the draft leaves to the operator and the source names as "[resourceId('Microsoft.Network/virtualNetworks/subnets', 'vnet-notes', 'snet-app')]"; the catalog Recipe takes the resource's literal identifier: write it virtual_network_subnet_id: ""환경 development는 템플릿이 환경을 지정하지 않아 가져오기가 쓰는 기본값입니다. 템플릿의 location 매개변수는 매개변수 파일이 제공하는 값 northeurope으로 정적 웹 앱과 사이트의 항목에 전달됩니다. 사이트의 service_plan_id는 템플릿이 적은 리터럴 식별자로 옮겨집니다. 네임스페이스의 항목은 비어 있으며, 그 위의 주석에는 초안이 변환하지 않는 모듈 매개변수가 나열됩니다.
키 하나가 비어 있으며, 그 주석이 이유를 설명합니다. virtual_network_subnet_id는 리소스에 대한 포인터이며, 표준 라이브러리의 Azure Resource Manager용 Recipes는 이를 리소스의 리터럴 /subscriptions/… 식별자로 받습니다. 템플릿은 사이트의 서브넷을 템플릿 자체의 리소스를 가리키는 resourceId 식으로 쓰는데, 식은 Recipe가 받을 수 있는 식별자가 아니므로 초안은 키를 비워 두고 그 식을 주석에 밝힙니다. 반면 초안으로 작성된 리소스는 템플릿의 모든 식을 그대로 유지합니다.
컨테이너 이미지는 항목에 없습니다. 템플릿은 이를 linuxFxVersion 안에 쓰는데, 초안은 이 속성을 어디에도 배치하지 않으며, 항목 위의 주석은 배치하지 않는 속성으로 kind와 linuxFxVersion을 나열합니다.
manifest.yaml — arm에서 각 컴포넌트를 구현하는 Recipe:
apiVersion: aggrega.ai/v1beta1kind: Manifestmetadata: name: imported/notes version: 0.1.0spec: mappings: components: type: {} name: ehmodule: arm/azure-event-hubs notes-site: arm/microsoft-web-staticsites notes-api: arm/server-app-service정적 웹 앱에는 표준 라이브러리의 Component가 없으므로, 가져오기는 워크스페이스의 catalog 폴더 아래에 Recipe와 함께 하나를 초안으로 작성합니다. Component imported/compute/microsoft-web-staticsites는 템플릿이 사이트에 부여한 name, location, 그리고 템플릿이 쓰는 모든 속성을 벤더 자체의 이름으로 담은 overrides 객체를 선언하고, Recipe microsoft-web-staticsites는 그 유형과 API 버전의 Microsoft.Web/staticSites 리소스를 하나 씁니다. 초안은 읽고 편집할 수 있는 일반 파일입니다.
apiVersion: aggrega.ai/v1beta1kind: Componentmetadata: name: imported/compute/microsoft-web-staticsites version: 0.1.0 description: "Draft Component of the resource type Microsoft.Web/staticSites@2023-01-01, imported from a source in the arm format." labels: component.aggrega.ai/type: resource component.aggrega.ai/category: compute component.aggrega.ai/hosting: managedspec: schema: values: type: object properties: # identity: the resource's own name or identifier # The source writing the resource gives no description of name. name: type: string required: true additionalProperties: false infra: type: object properties: # placement: where the resource is deployed # The source writing the resource gives no description of location. location: type: string required: true # override: every writable property no other rule places, each under the vendor's own name overrides: type: object description: "Writable settings of Microsoft.Web/staticSites@2023-01-01, each under the vendor's own name, which the Recipe passes to the resource as written; its header lists the names it reads." additionalProperties: true additionalProperties: false[… omitted: the values the Component publishes, id and name]release.lock은 Release가 확인한 카탈로그 엔터티를 다이제스트와 함께 기록합니다. .aggrega-import.json은 가져오기가 작성한 내용의 기록이며, 이후의 aggrega import --sync가 이를 읽습니다.
검증
aggrega validate --release release.yaml검증이 중단됩니다. 초안에는 사이트의 서브넷이 지정되어 있지 않고, App Service Recipe는 사이트를 작성자 자신의 네트워크 서브넷에 그 식별자로만 참여시키기 때문입니다:
[CATALOG_ERROR E0033] Recipe/FeatureRecipe assertions[… omitted: the line beginning "caused by: Recipe "server-app-service" instance "notes-api" assertion "placement_supplied"", which ends with the Recipe's message: … infra.overrides.virtual_network_subnet_id is "", and this Recipe takes the subnet the app joins by virtual network integration as the subnet's resource ID: set it to /subscriptions/<subscription>/resourceGroups/<group>/providers/Microsoft.Network/virtualNetworks/<network>/subnets/<subnet>, a subnet delegated to Microsoft.Web/serverFarms, or remove it]release dependency validation failed: 1 diagnostic(s)거부는 무엇을 어디에서 바꿔야 하는지를, 바꿀 문서 안에서 밝힙니다. 여기서는 release.yaml의 notes-api 항목이며, 서브넷 다음으로 빌드는 두 번째 값인 컨테이너 이미지를 밝힙니다. 템플릿은 이를 초안이 배치하지 않는 linuxFxVersion에 쓰고, App Service용 범용 서버의 Recipe는 자체 이미지를 갖고 있지 않으므로, 빌드는 Release가 infra.image를 설정하지 않았다는 메시지와 함께 멈춥니다. 이미지는 Release에서 작성자가 직접 제공해야 합니다.
네임스페이스의 주석에는 skuName, skuCapacity, location이 나열되어 있습니다. 모듈은 이들을 템플릿에서 받지만 초안은 이들도 배치하지 않습니다. 이들이 없으면 Recipe 자체의 기본값이 적용되며, 템플릿의 값은 infra.overrides.sku_name, infra.overrides.sku_capacity, infra.overrides.location이 옮깁니다. 예제의 reviewed 폴더에는 이들을 모두 적은 release.yaml이 있습니다:
# Module parameters the source sets and the draft does not translate: location, name, publicNetworkAccess, skuCapacity, skuName. ehmodule: infra: overrides: # Where the template sets skuName and skuCapacity, which the draft places nowhere: the namespace's tier and its throughput units. sku_name: "Standard" sku_capacity: 2 # Where the template sets location, which the draft places nowhere on a module: the namespace's region. location: "northeurope"그리고 이미지와 서브넷을 포함한 사이트의 항목입니다:
# Properties the source writes and the draft does not place: kind, properties.siteConfig.linuxFxVersion. # Environment variables the source sets and no connection delivers: EVENTHUB_NAME = notes. notes-api: infra: # The template writes the container image in properties.siteConfig.linuxFxVersion, which the draft places nowhere: the image the site runs. image: "ghcr.io/example/notes-api:2.3.0" overrides: service_plan_id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/notes-platform/providers/Microsoft.Web/serverfarms/plan-notes" # From the template parameter location, the value the parameters file supplies. location: "northeurope" # The subnet the template's virtual network holds, as the literal ID the Recipe takes, in the resource group the network is deployed to. virtual_network_subnet_id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/notes-network/providers/Microsoft.Network/virtualNetworks/vnet-notes/subnets/snet-app"예제의 검사 스크립트는 이 Release를 빌드하고, 초안이 위의 메시지와 함께 중단되는지 확인합니다.
빌드
검토를 마친 Release가 들어 있는 폴더로 이동하거나, source의 release.yaml을 같은 방식으로 편집한 다음 빌드합니다.
aggrega validate --release release.yamlaggrega build --release release.yaml --auto-pullRelease가 가져오기가 쓴 release.lock과 더 이상 일치하지 않으므로, 빌드에는 이를 다시 확인하는 --auto-pull이 필요합니다. 이것이 없으면 빌드는 중단되며 aggrega pull을 지목합니다. 검증은 다음과 같이 출력합니다.
release dependency validation passed: release.yaml (schema-pillar + dependency pillars)그리고 빌드는 다음과 같습니다. 여기서 <workspace>는 실행한 폴더를 나타냅니다:
[… omitted: the pull's line reporting the lockfile it wrote][… omitted: a total build time, which differs per run]Build completed: 1 file written to <workspace>/distarm-template.json 읽기
빌드는 파일 하나, dist/arm/arm-template.json을 작성합니다. 언어 버전 2.0으로 조립된 템플릿이며, resources 아래에 컴포넌트가 쓰는 리소스마다 항목이 하나씩 있고, 항목 이름은 컴포넌트의 인스턴스 ID를 단어로 풀어 쓴 것입니다:
Ehmodule the Event Hubs namespace, in a nested templateNotesApi the App Service siteNotesApiFtpPublishing the site's FTP publishing policy, which the Recipe turns offNotesApiScmPublishing the site's SCM publishing policy, which the Recipe turns offNotesSite the static web app, the resource the draft Recipe writes네임스페이스의 항목에는 Recipe가 쓰는 네임스페이스가 들어 있고, Release가 담은 설정(등급, 처리량 단위, 리전)이 반영되며, 나머지는 Recipe 자체의 설정입니다:
"Ehmodule": { "apiVersion": "2025-04-01", "metadata": { "aggrega.ai/provenance": { "aggrega.ai/aggregate-name": "imported/notes", "aggrega.ai/boundary-path": "default",[… omitted: a compiler-version entry, which moves with the build] "aggrega.ai/component-id": "ehmodule", "aggrega.ai/environment": "development", "aggrega.ai/provider": "arm",[… omitted: a provider-version entry, which moves with the build] "aggrega.ai/recipe-uri": "azure-event-hubs:1.0.0" } }, "name": "[format('Ehmodule-{0}', uniqueString(deployment().name))]", "properties": { "expressionEvaluationOptions": { "scope": "inner" }, "mode": "Incremental", "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "outputs": { "serviceBusEndpoint": { "type": "string", "value": "[reference(resourceId('Microsoft.EventHub/namespaces', 'ehmodule'), '2026-01-01').serviceBusEndpoint]" } }, "resources": [ { "apiVersion": "2026-01-01", "location": "northeurope", "name": "ehmodule", "properties": { "disableLocalAuth": true, "isAutoInflateEnabled": false, "minimumTlsVersion": "1.2", "publicNetworkAccess": "Enabled" }, "sku": { "capacity": 2, "name": "Standard", "tier": "Standard" }, "type": "Microsoft.EventHub/namespaces" } ] } }, "type": "Microsoft.Resources/deployments" },사이트의 항목에는 플랜, 서브넷, 사이트가 실행하는 컨테이너로서의 이미지, 범용 서버가 선언하는 포트가 들어 있습니다:
"NotesApi": { "apiVersion": "2025-03-01", "kind": "app,linux,container", "location": "northeurope", "metadata": { "aggrega.ai/provenance": { "aggrega.ai/aggregate-name": "imported/notes", "aggrega.ai/boundary-path": "default",[… omitted: a compiler-version entry, which moves with the build] "aggrega.ai/component-id": "notes-api", "aggrega.ai/environment": "development", "aggrega.ai/provider": "arm",[… omitted: a provider-version entry, which moves with the build] "aggrega.ai/recipe-uri": "server-app-service:1.0.0" } }, "name": "notes-api", "properties": { "clientAffinityEnabled": false, "httpsOnly": true, "publicNetworkAccess": "Disabled", "serverFarmId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/notes-platform/providers/Microsoft.Web/serverfarms/plan-notes", "siteConfig": { "alwaysOn": true, "appSettings": [ { "name": "WEBSITES_PORT", "value": "8080" } ], "ftpsState": "Disabled", "linuxFxVersion": "DOCKER|ghcr.io/example/notes-api:2.3.0", "minTlsVersion": "1.2", "vnetRouteAllEnabled": true }, "virtualNetworkSubnetId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/notes-network/providers/Microsoft.Network/virtualNetworks/vnet-notes/subnets/snet-app" }, "type": "Microsoft.Web/sites" },사이트는 WEBSITES_PORT만 받고 템플릿이 설정한 것은 받지 않습니다. EVENTHUB_NAMESPACE와 EVENTHUB_NAME은 초안이 전달하지 않은 변수이며, warn 줄과 주석이 이를 알려 줍니다. 네임스페이스의 이름은 템플릿에서는 evh-notes였으나 여기서는 컴포넌트의 이름인 ehmodule입니다. 모듈의 name은 Recipe가 설정하며, 항목 위의 주석은 이를 초안이 변환하지 않는 매개변수 중 하나로 나열합니다.
배포하기
이 템플릿은 리소스 그룹 템플릿입니다. 빌드는 매개변수 파일을 작성하지 않으며 Azure에 대해 아무것도 실행하지 않으므로, 명령은 직접 실행해야 합니다. 템플릿이 무엇을 변경할지 미리 보고, 그런 다음 배포합니다:
az deployment group what-if --resource-group <group> --template-file dist/arm/arm-template.jsonaz deployment group create --resource-group <group> --name <name> --template-file dist/arm/arm-template.jsonARM 프로바이더 페이지에서 이 명령들, 관리를 중단한 것을 절대 삭제하지 않는 스택, 각 플래그가 결정하는 내용을 설명합니다. 템플릿을 배포하기 전에, Release가 지명하지만 템플릿이 배포하지 않는 리소스가 존재해야 합니다. 사이트가 참여하는 App Service 플랜과 서브넷이며, 서브넷은 Microsoft.Web/serverFarms에 위임되어 있습니다.
AI 어시스턴트 사용
Aggrega의 도구로 설정된 AI 어시스턴트도 같은 일을 할 수 있습니다. 다음 프롬프트를 붙여 넣으십시오.
Aggrega 도구만 사용하고, 폴더를 직접 만들지 마세요. Workspace 폴더에 아직 `import-arm` 폴더가 없으면, `example`을 `import-arm`으로 설정하고 `dir`은 지정하지 않은 채 `draft` 도구를 한 번 호출하세요. 이 도구는 예제를 새 `import-arm` 폴더에 작성합니다. 그런 다음 `workspace_root`를 `import-arm/source`로, `source`를 `notes`로 설정하여 `import` 도구를 호출하세요. 이 도구는 초안을 `import-arm/source`에 작성하고 초안에 필요한 것을 가져옵니다. 그런 다음 `workspace_root`를 `import-arm/reviewed`로, `release`를 `release.yaml`로, `auto_pull`을 true로, `write`를 true로 설정하여 `build` 도구를 호출하세요. 빌드가 어떤 파일을 작성했는지 알려 주세요. 파일은 `import-arm/reviewed/dist/` 아래에 있습니다.reviewed 폴더에는 검증에 나열된 값을 작성한 초안이 들어 있습니다. 직접 작성한 초안을 검토하려면, 먼저 어시스턴트에게 import-arm/source를 검증하게 하고 어디에서 멈추는지 알려 달라고 요청하세요.
VS Code에서 열기
Visual Studio Code용 Aggrega 확장을 설치한 상태에서, 가져오기가 초안을 작성한 폴더 import-arm/source를 VS Code에서 엽니다. 이 폴더에는 Release가 하나, 즉 초안으로 작성된 release.yaml만 있으므로 편집기가 이를 자동으로 선택하고, 초안을 편집하는 동안 그 Release를 기준으로 검사하여 발견한 내용을 파일과 문제 패널에 표시합니다. 명령 팔레트의 Aggrega: Show topology graph는 Release의 컴포넌트와 그 사이의 연결을 그립니다. Aggrega: Build, Aggrega: Preview build, Aggrega: Pull은 같은 Release에 대해 동작하며, 각각 작업 표시줄의 Aggrega 보기에 있는 Commands 패널의 버튼으로도 제공됩니다. Build는 폴더의 dist/에 파일을 작성합니다. 나머지 내용은 Visual Studio Code에서 Aggrega 사용하기에서 다룹니다.
템플릿이 변경될 때
.aggrega-import.json을 초안 옆에 그대로 두고, 템플릿이 변경된 뒤 다음을 실행합니다:
aggrega import notes --sync이 명령은 기록이 보관하는 대상인 arm을 읽고, 가져오기가 작성한 것만 변경합니다. main.json에서 정적 웹 앱의 outputLocation이 dist에서 build로 바뀌면 가져오기는 다음과 같이 출력합니다:
changed spec.components.notes-site.infra.overrides.outputLocation in release.yaml그리고 그 한 줄만 바뀐 release.yaml을 작성하며, 그 옆에 직접 작성한 값은 그대로 유지됩니다. 소스가 건드리지 않은 부분은 편집 여부와 관계없이 디스크에 있는 그대로 유지됩니다. 소스가 직접 편집한 부분을 변경한 경우에는 멈추고, 그 부분을 지목하고, 아무것도 쓰지 않으므로 직접 조정해야 합니다. aggrega import에 규칙과 모든 플래그가 자세히 설명되어 있습니다.
옆에 있는 템플릿을 연결하는 템플릿
템플릿은 templateLink.relativePath가 옆에 있는 파일을 지정하는 Microsoft.Resources/deployments 리소스를 통해 다른 템플릿을 배포할 수 있습니다. 가져오기는 가져온 디렉터리 안에서 연결된 템플릿을 읽습니다. 루트인 템플릿 하나에서 시작해 루트가 연결하는 각 템플릿을 읽고, 그 모두의 리소스를 하나의 Aggregate로 초안 작성합니다.
여러 템플릿이 들어 있는 디렉터리는 무엇이 무엇을 연결하는지에 따라 루트를 정합니다. 루트는 다른 어떤 템플릿에서도 연결되지 않는 하나의 템플릿입니다. 서로 연결되지 않은 두 템플릿이 들어 있는 디렉터리에는 단일 루트가 없으므로, 가져오기는 멈추고 두 템플릿을 모두 지목합니다:
halt: the sources network.json, site.json are each linked by no other source, and the root setting names none of them: set root to the path of the one to start fromroot 설정은 워크스페이스 구성의 임포터 항목에서 시작할 템플릿을 지정합니다. uri는 임포터를 그 식별자와 실행 중인 컴파일러의 버전으로 지정하며, aggrega plugin add importer가 기록하는 방식 그대로입니다(어떤 임포터가 소스를 초안으로 변환하는가):
plugins: importer: - uri: importer/arm:<version> with: settings: root: site.jsonroot를 설정하면 가져오기는 site.json과 그것이 연결하는 템플릿을 읽고, network.json은 제외합니다.
가져온 디렉터리를 벗어나는 링크(../shared/dns.json)는 읽지 않습니다. 가져오기는 지정된 디렉터리 밖의 파일을 절대 열지 않습니다. 리소스와 경로를 지목하여 경고하고, 그 리소스를 독립된 하나의 리소스로 초안 작성하며, 템플릿이 읽는 그 템플릿의 각 출력을 템플릿이 배포될 때 그것을 평가하는 표현식으로 담습니다:
warn: dns is a Microsoft.Resources/deployments resource of main.json whose template is linked by a relative path leaving the imported directory, which the import does not read: no resource of that template is drafted, and each of its outputs the template reads is carried as text evaluated when the template deploys; to draft its resources, place the linked template inside the imported directory and link it by templateLink.relativePath연결된 템플릿을 가져온 디렉터리 안에 두면 다음 가져오기가 그것을 읽습니다.
이름이 이미 사용 중일 때
초안이 Component로 만드는 리소스는 가져오기가 그 유형에서 고르는 이름을 갖습니다. 정적 웹 앱의 경우 imported/compute/microsoft-web-staticsites입니다. 그 이름의 Component가 이미 워크스페이스의 카탈로그 폴더나 hub에 있고 이번 가져오기가 초안으로 작성한 것이 아니라면, 가져오기는 이를 덮어쓰지 않고 추측하지도 않습니다. 리소스를 보류하여 초안으로 작성하지도 참조하지도 않고 경고합니다. 첫 번째 가져오기가 Component를 워크스페이스의 catalog 폴더에 작성한 뒤, 같은 워크스페이스의 다른 폴더로 --output-dir second를 지정하여 예제를 두 번째로 가져오면 다음과 같이 출력됩니다:
warn: notes-site (Microsoft.Web/staticSites) is held back: the catalog holds the Component imported/compute/microsoft-web-staticsites a draft of it takes, which this import did not draft, so the resource is neither drafted nor referenced; to reference it, write in the importer's settings the entry {"mapping_overrides":{"arm":{"Microsoft.Web/staticSites":{"component":"imported/compute/microsoft-web-staticsites","category":"compute","traits":{"component.aggrega.ai/hosting":"managed","component.aggrega.ai/type":"resource"},"vendor":"staticsites"}}}}, then fill the instance's infra in the Release임포터 항목의 mapping_overrides 설정은 형식 arm, 그다음 리소스 유형을 키로 하여, 그 유형을 이미 있는 Component에 매핑하며, 경고가 출력하는 항목이 바로 작성해야 할 항목입니다(설정). 이를 설정하면 다음 가져오기는 그 Component를 참조합니다. notes-site는 참조로 매핑되고, Release에 있는 그 항목에는 템플릿이 작성하는 속성을 지목하는 주석 외에 키가 없습니다:
notes-site: {}Component는 필수 name과 location을 선언하는데 초안은 둘 다 작성하지 않으므로, 가져오기는 초안을 작성한 채 각각이 누락되었다고 보고하며 끝납니다. 이들과 주석이 나열하는 속성을 Component가 선언하는 대로 Release에 작성하세요.
초안이 직접 처리하도록 남기는 것
가져오기는 템플릿이 명시한 내용과 카탈로그가 결정하는 내용을 초안으로 작성하고, 어디에서 멈췄는지 알려 줍니다. 템플릿의 경우 다음이 남습니다:
- 템플릿이 다른 것을 지원하기 위해 만드는 기반. 가상 네트워크
vnet-notes와 그 서브넷은 사이트를 위해 템플릿에 존재합니다. 초안은 네트워크를 만들지 않습니다. 카탈로그의 Component는 자신이 실행되는 네트워크를infra.overrides아래에서 리소스 ID로 받으며, 그 네트워크는 사용자의 몫입니다.warn줄은 그러한 리소스를 각각 지목하고, 그것을 가리키던 포인터는 Release의 빈 키가 됩니다. Release가 배포되는 곳에는 네트워크와 서브넷이 이미 존재하거나, 가져온 템플릿으로 직접 배포해야 합니다. - 초안이 배치하지 않는 값. Release의 각 항목 주석에는 초안이 배치하지 않는 모듈 매개변수와 리소스 속성이 나열되어 있습니다. 여기서는 네임스페이스의 등급, 처리량 단위, 리전, 이름과 사이트의
kind,linuxFxVersion이 해당하며, 따라서 템플릿의 설정은 조용히 버려지지 않고 명시됩니다. Component에 그것을 둘 자리가 있으면, 검증 섹션이 하는 것처럼 직접 작성합니다. - 어떤 연결도 전달하지 않는 환경 변수. 사이트의
EVENTHUB_NAMESPACE와EVENTHUB_NAME은 Aggregate와 Release의 주석에 지목되어 있고, 각각warn줄에도 지목되어 있습니다. 사이트를 Release에서 구성하는 경우, 이를 직접 설정합니다. - 컨테이너 이미지. 초안은 템플릿이 초안이 배치하는 속성에 이미지를 명시한 경우에만 이미지를 담습니다. 이 템플릿은 이미지를
linuxFxVersion에 쓰므로 초안은 아무것도 담지 않고, 빌드는infra.image를 지목하며 멈춥니다. 이미지는 Release에서 직접 제공해야 합니다.
표준 라이브러리가 아무것도 매핑하지 않는 모듈은 통째로 유지됩니다. 템플릿이 임포터의 어떤 행도 매핑하지 않는 리소스 유형의 Azure Verified Modules 모듈을 배포하면, 가져오기는 그 모듈을 oci://mcr.microsoft.com/bicep/<path>로 소스로 삼고 텔레메트리를 끈 Component와 Recipe를 초안으로 작성하며, 시크릿으로 채워지는 모듈 매개변수는 제외되고 경고됩니다. 어떤 행도 매핑하지 않는 유형의 리소스는 정적 웹 앱처럼 템플릿에서 초안으로 작성되며, 초안의 전환 힌트는 aggrega import --format arm-schema를 지목하는데, 이는 카탈로그에 없는 서비스 배포하기에서 설명하듯 같은 Component를 대신 벤더의 스키마에서 초안으로 작성합니다.
여러 줄에 걸쳐 작성된 문자열
JSON은 문자열 안에 원시 줄바꿈을 허용하지 않으며, 임포터는 템플릿을 JSON으로 읽습니다. 줄바꿈이 있는 템플릿, 예를 들어 scriptContent 값에 여러 줄에 걸쳐 작성된 스크립트는 읽기에 실패하므로 인식되지 않습니다:
[E0350] no importer recognises the source (source "main.json"). Pass --format to name it explicitly (for example --format agent-framework, --format arm-schema, --format arm, --format cloudformation-schema, --format compose, --format crewai, --format dify, --format flowise, --format google-adk, --format langflow, --format langgraph, --format mcp, --format n8n or --format terraform-schema)그리고 --format arm을 지정하면 가져오기는 위치를 지목하며 중단됩니다:
halt: could not parse source "main.json" as arm: json parse: invalid character '\n' in string literal at line 14, column 35각 문자열을 한 줄로 작성하고 텍스트가 줄바꿈되는 곳에 \n을 넣으면 가져오기가 읽습니다.