Mengimpor template Azure Resource Manager
Panduan langkah demi langkah ini mengimpor sebuah template Azure Resource Manager kecil — sebuah namespace Event Hubs yang di-deploy melalui modul Azure Verified Modules, sebuah situs App Service yang menjalankan container, sebuah static web app, dan virtual network yang dimaksudkan untuk diikuti situs tersebut — lalu membangun hasilnya sebagai satu template Azure Resource Manager. Impor membuat draf Aggregate, Release, dan Manifest: namespace dan situs menjadi referensi ke Components pustaka standar, static web app, yang tidak diwakili oleh Component mana pun, didrafkan dari template, dan nilai yang dinyatakan template dalam bentuk yang dapat diterima Release dibawa. Beberapa nilai yang tidak dibawanya diserahkan kepada Anda, dan halaman ini menunjukkan nilai mana dan di mana. Setiap file dan setiap blok keluaran di bawah ini berasal dari eksekusi nyata; template dan setiap tahap panduan ada dalam contoh import-arm, tempat sebuah skrip pemeriksaan menjalankan impor lagi, membandingkan apa yang ditulisnya, apa yang dicetaknya, dan blok yang dikutip halaman ini dengan file yang disimpan di sana, memastikan draf berhenti di tempat yang dikatakan halaman ini, dan membangun Release yang sudah ditinjau.
Menyusun draf contoh
Anda dapat menjalankan impor ini dengan perintah di halaman ini, atau meminta asisten AI Anda menjalankannya untuk Anda.
Tulis contoh ke folder baru yang dinamai sesuai contoh itu:
aggrega draft --example import-armKemudian ia mencetak perintah yang dijalankan berikutnya. Perintah pertama berpindah ke folder baru; perintah sesudahnya, di bawah, berpindah ke folder source milik folder baru itu, yang berisi apa yang diimpor halaman ini dan merupakan tempat impor dijalankan:
cd import-armTemplate
main.json adalah bentuk terkompilasi dari sebuah template: JSON yang ditulis oleh build Bicep, yang di-deploy oleh Azure Resource Manager. Parameternya adalah region, dan file ini diawali dengan virtual network yang memuat subnet yang diikuti situs:
{ "$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]Namespace di-deploy melalui modul Azure Verified Modules avm/res/event-hub/namespace pada versi 0.15.3: sebuah resource Microsoft.Resources/deployments yang anggota template-nya memuat template terkompilasi milik modul itu sendiri, lebih dari 3.700 barisnya, dan yang parameters-nya adalah apa yang ditetapkan template untuk modul:
{ "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]Template terkompilasi modul adalah yang disajikan Microsoft Container Registry untuk versi tersebut, berlisensi MIT, dan README contoh memuat pemberitahuannya. Impor membacanya untuk mengenali modul: prefiks telemetri dan versinya menyebut modul Azure Verified Modules dan tipe resource yang di-deploy-nya.
Situs ini adalah resource biasa. Situs berjalan pada App Service plan yang sudah ada, bergabung dengan subnet milik template, menjalankan container yang disebut dalam linuxFxVersion, membaca output name milik modul, dan menetapkan satu variabel lagi:
{ "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" } ] } } },Static web app juga resource biasa. Di samping template, sebuah file parameter menyediakan satu parameter:
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { "location": { "value": "northeurope" } }}Kedua file berada di folder notes, dan sebuah .aggrega-config.yaml di samping folder itu menjadikan direktori tersebut sebuah workspace, sehingga impor menulis drafnya di sana:
# 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.aiImpor membaca template dan file parameternya sebagai JSON dengan komentar, mengenali template dari $schema dan resources-nya, dan file parameter dari $schema dan parameters-nya. Impor menimbang setiap resource terhadap Components katalog workspace, yang dibacanya seperti dijelaskan Cara impor berjalan, dan tidak membaca akun cloud mana pun: nilai yang dihitung template saat di-deploy dibawa sebagai ekspresi yang menghitungnya, tidak pernah dicari.
Pindah ke source:
cd sourceMenjalankan impor
Sebutkan folder yang memuat template. Importer mengenali template dan file parameternya dari isinya:
aggrega import notesTidak ada --target yang disebut. Importer mendeklarasikan arm sebagai target bawaannya, karena Recipes pustaka standar untuk Azure Resource Manager terikat padanya, dan impor membuat draf Manifest untuknya; impor yang menyebut target, dengan --target, membuat draf untuk target itu. Catatan yang ditulis impor di samping drafnya menyimpan target tersebut, dan --sync memakainya kembali.
Pada keluaran standar, impor mencantumkan apa yang ditulisnya:
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.jsonPada galat standar, dengan <workspace> mewakili folder tempat Anda menjalankannya:
[… 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)- Baris
infomenyatakan apa yang diputuskan importer tanpa pertanyaan. Baris pertama menyatakan bahwa draf ditujukan untukarm. Baris kedua mengenali modul: resourceehmoduleadalah modul Azure Verified Modules dari namespace Event Hubs, dan parameter yang ditetapkan template untuknya terbaca sebagai parameter milik modul itu, sehingga draf memperlakukannya sebagai satu namespace dan bukan sebagai template bersarang yang harus dibaca. Baris ketiga menyatakan bahwa static web app didrafkan dari template. - Baris
warnmenyebut apa yang tidak dibawa draf. Baris pertama adalah variabel yang dibaca situs dari outputnamemilik modul: draf hanya menghubungkan koneksi untuk apa yang dipublikasikan sebuah Component, dan namespace tidak mempublikasikan key untuk namanya, sehingga koneksi itu hanya ada demi dependensi. Baris kedua menyebut virtual network yang dibuat template, yang diserahkan draf kepada Anda, seperti dijelaskan Apa yang diserahkan draf kepada Anda. Baris ketiga menyebut variabel yang ditetapkan situs yang tidak dikirim oleh koneksi mana pun dalam draf. - Baris
mappedmenyatakan menjadi apa setiap resource.ehmoduleadalah instans daricore/messaging/azure-event-hubsmilik pustaka standar, dannotes-apiadalah instans dari server generik,core/compute/server, masing-masing dicocokkan pada tingkat tinggi dan direferensikan.notes-sitetidak cocok dengan Component mana pun, sehingga ia berupa draf, tanpa kecocokan. Barismade no choicemenyebut apa yang tidak diputuskan draf: virtual network, dan penunjuk subnet yang dibiarkan kosong oleh Release. - Pull adalah impor yang mengambil apa yang menjadi dependensi Release hasil draf, seperti yang dilakukan
aggrega pull, ke dalamrelease.lock. Recipes yang disebut Manifest untuk namespace dan situs menulis resource-nya sendiri dan tidak mengambil apa pun dari sumber, sehinggasource_artifactsbernilai0dan pull tidak menjangkau apa pun di luar katalog. Impor kemudian mencoba me-render Release untuk menemukan input yang akan diambil build, dan Recipe App Service menghentikannya: draf belum menyebut subnet. Impor tetap selesai, dengan lockfile tertulis, dan menyatakan bahwa input eksternal tidak ditemukan sepenuhnya; penghentian itu adalah yang dilaporkan validasi berikutnya.
Apa yang ditulisnya
Aggregate, Release, dan Manifest diberi nama imported/notes, berdasarkan folder yang dibaca impor — template yang diimpor sebagai file dinamai berdasarkan file itu, main — di bawah namespace yang ditetapkan oleh pengaturan target_namespace milik importer, yaitu imported kecuali Anda menetapkan yang lain (Pengaturan).
aggregate.yaml — satu entri per resource, dan koneksi yang digambar situs:
# 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: ehmoduleStatic web app adalah komponen dari sebuah tipe yang didrafkan impor, imported/compute/microsoft-web-staticsites. Koneksi situs ke namespace tidak memiliki blok inject, karena draf hanya mengirim variabel dari sebuah koneksi bila Component mempublikasikan nilainya, dan komentar di atasnya menyebut variabel mana yang tidak dihubungkannya dan mengapa.
release.yaml — lingkungan dan pengaturan setiap resource:
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: ""Lingkungan, development, adalah nilai bawaan yang ditulis impor karena tidak ada template yang menyebutnya. Parameter location milik template sampai ke entri static web app dan situs sebagai nilai yang disediakan file parameter, northeurope. service_plan_id milik situs dibawa sebagai identifier literal yang ditulis template. Entri namespace kosong, dan komentar di atasnya mencantumkan parameter modul yang tidak diterjemahkan draf.
Satu key kosong, dan komentarnya menjelaskan alasannya: virtual_network_subnet_id adalah penunjuk ke sebuah resource, yang diterima Recipes pustaka standar untuk Azure Resource Manager sebagai identifier literal /subscriptions/… dari resource tersebut. Template menulis subnet situs sebagai ekspresi resourceId yang menyebut resource milik template itu sendiri, dan sebuah ekspresi bukan identifier yang dapat diterima Recipe, sehingga draf membiarkan key kosong dan menyebut ekspresi itu dalam komentar. Sebaliknya, resource yang didrafkan mempertahankan setiap ekspresi template secara utuh.
Image container tidak ada dalam entri. Template menuliskannya di dalam linuxFxVersion, sebuah properti yang tidak ditempatkan draf di mana pun, dan komentar di atas entri mencantumkan kind dan linuxFxVersion di antara properti yang tidak ditempatkannya.
manifest.yaml — Recipe yang dipakai merealisasikan setiap komponen pada arm:
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-serviceStatic web app tidak memiliki Component pustaka standar, sehingga impor membuat draf satu beserta Recipe di bawah folder catalog workspace: Component imported/compute/microsoft-web-staticsites mendeklarasikan name yang diberikan template pada situs, sebuah location, dan objek overrides untuk setiap properti yang ditulis template, dengan nama milik vendor sendiri, dan Recipe microsoft-web-staticsites menulis satu resource Microsoft.Web/staticSites dengan tipe dan versi API tersebut. Draf ini adalah file biasa untuk Anda baca dan sunting:
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 mencatat entitas katalog yang diselesaikan Release, berdasarkan digest; .aggrega-import.json adalah catatan tentang apa yang ditulis impor, yang dibaca oleh aggrega import --sync berikutnya.
Validasi
aggrega validate --release release.yamlValidasi berhenti. Draf tidak menyebut subnet untuk situs, dan Recipe App Service menggabungkan situs ke subnet milik jaringan Anda sendiri hanya melalui identifier-nya:
[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)Penolakan menyebut apa yang harus diubah dan di mana, dalam dokumen yang Anda ubah. Di sini itu adalah entri notes-api pada release.yaml, dan setelah subnet, build menyebut nilai kedua: image container. Template menuliskannya dalam linuxFxVersion, yang tidak ditempatkan draf, dan Recipe server generik untuk App Service tidak memiliki image sendiri, sehingga build berhenti dengan pesan bahwa Release tidak menetapkan infra.image. Image itu Anda yang menyediakan di Release.
Komentar namespace mencantumkan skuName, skuCapacity, dan location, yang diambil modul dari template dan juga tidak ditempatkan draf. Tanpa nilai-nilai itu, nilai bawaan milik Recipe berlaku; infra.overrides.sku_name, infra.overrides.sku_capacity, dan infra.overrides.location membawa nilai milik template. Folder reviewed pada contoh memuat release.yaml dengan semuanya telah ditulis:
# 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"dan entri situs, dengan image dan subnet:
# 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"Skrip pemeriksaan contoh membangun Release ini, dan memastikan bahwa draf berhenti dengan pesan di atas.
Build
Pindah ke folder yang memuat Release yang sudah ditinjau, atau sunting release.yaml di source dengan cara yang sama, lalu bangun:
aggrega validate --release release.yamlaggrega build --release release.yaml --auto-pullRelease tidak lagi cocok dengan release.lock yang ditulis impor, sehingga build memerlukan --auto-pull, yang menyelesaikannya kembali; tanpa itu build berhenti dan menyebut aggrega pull. Validasi mencetak:
release dependency validation passed: release.yaml (schema-pillar + dependency pillars)dan build, dengan <workspace> mewakili folder tempat Anda menjalankannya:
[… 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>/distMembaca arm-template.json
Build menulis satu file, dist/arm/arm-template.json: template yang sudah dirakit, dalam versi bahasa 2.0, dengan satu entri di bawah resources untuk setiap resource yang ditulis sebuah komponen, dinamai dari id instans komponen yang diubah menjadi kata-kata:
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 writesEntri namespace memuat namespace yang ditulis Recipe, dengan pengaturan yang dibawa Release — tier, throughput unit, dan region — dan pengaturan milik Recipe sendiri untuk sisanya:
"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" },Entri situs membawa plan, subnet, image sebagai container yang dijalankan situs, dan port yang dideklarasikan server generik:
"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" },Situs menerima WEBSITES_PORT dan tidak ada yang ditetapkan template: EVENTHUB_NAMESPACE dan EVENTHUB_NAME adalah variabel yang tidak dikirim draf, yang disebut oleh baris warn dan komentar. Nama namespace adalah ehmodule, nama komponen, sedangkan template menamainya evh-notes: name modul ditetapkan oleh Recipe, dan komentar di atas entri mencantumkannya di antara parameter yang tidak diterjemahkan draf.
Men-deploy-nya
Template ini adalah template resource group. Build tidak menulis file parameter dan tidak menjalankan apa pun terhadap Azure: perintahnya Anda yang menjalankan. Pratinjau apa yang akan diubah template, lalu deploy:
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.jsonHalaman provider ARM menguraikan perintah-perintah ini, stack yang tidak pernah menghapus apa yang berhenti dikelolanya, dan apa yang ditentukan setiap flag. Sebelum template di-deploy, resource yang disebut Release tetapi tidak di-deploy template harus sudah ada: App Service plan dan subnet yang diikuti situs, yang didelegasikan ke Microsoft.Web/serverFarms.
Dengan asisten AI
Asisten AI yang disiapkan dengan alat-alat Aggrega dapat melakukan hal yang sama: tempelkan prompt ini ke dalamnya.
Gunakan hanya alat Aggrega, dan jangan membuat folder sendiri. Jika folder Workspace belum berisi folder `import-arm`, panggil alat `draft` sekali dengan `example` diatur ke `import-arm` dan tanpa `dir`: alat ini menulis contoh ke folder `import-arm` baru. Lalu panggil alat `import` dengan `workspace_root` diatur ke `import-arm/source` dan `source` diatur ke `notes`: alat ini menulis drafnya ke `import-arm/source` dan menarik apa yang dibutuhkan draf tersebut. Lalu panggil alat `build` dengan `workspace_root` diatur ke `import-arm/reviewed`, `release` diatur ke `release.yaml`, `auto_pull` diatur ke true, dan `write` diatur ke true. Beri tahu saya file mana yang ditulis build; file-file itu ada di bawah `import-arm/reviewed/dist/`.Folder reviewed berisi draf dengan nilai yang sudah ditulis, seperti yang dicantumkan Validasi; untuk meninjau draf Anda sendiri, minta asisten memvalidasi import-arm/source terlebih dahulu dan memberi tahu Anda di mana ia berhenti.
Membukanya di VS Code
Dengan ekstensi Aggrega untuk Visual Studio Code terpasang, buka folder import-arm/source di VS Code, tempat impor menulis drafnya. Folder ini berisi satu Release, yaitu release.yaml hasil draf, sehingga editor memilihnya untuk Anda, dan memeriksa draf terhadap Release tersebut saat Anda menyuntingnya, menandai temuannya di file dan di panel Problems. Aggrega: Show topology graph, di Command Palette, menggambar komponen Release dan koneksi di antaranya. Aggrega: Build, Aggrega: Preview build, dan Aggrega: Pull bekerja pada Release yang sama, dan masing-masing juga merupakan tombol di panel Commands pada tampilan Aggrega di activity bar; Build menulis file-filenya ke dist/ milik folder tersebut. Menggunakan Aggrega di Visual Studio Code membahas sisanya.
Saat template berubah
Simpan .aggrega-import.json di samping draf, dan setelah template berubah jalankan:
aggrega import notes --syncPerintah ini membaca target yang disimpan catatan, arm, dan hanya mengubah apa yang ditulis impor. Setelah outputLocation milik static web app berubah dari dist menjadi build di main.json, impor menyatakan:
changed spec.components.notes-site.infra.overrides.outputLocation in release.yamldan menulis release.yaml dengan satu baris itu berubah; nilai yang Anda tulis di sampingnya tetap seperti adanya. Bagian yang tidak diubah sumber tetap seperti adanya di disk, diedit atau tidak; jika sumber mengubah bagian yang Anda edit, perintah ini berhenti, menyebut bagian tersebut, dan tidak menulis apa pun, agar Anda merekonsiliasinya secara manual. aggrega import menjelaskan aturan dan setiap flag secara lengkap.
Template yang menautkan template di sampingnya
Sebuah template dapat men-deploy template lain melalui resource Microsoft.Resources/deployments yang templateLink.relativePath-nya menyebut file di sampingnya. Impor membaca template tertaut di dalam direktori yang diimpor: ia mulai dari satu template, yaitu root, membaca setiap template yang ditautkan root, dan mendrafkan resource semuanya sebagai satu Aggregate.
Direktori yang berisi beberapa template menentukan root-nya dari apa yang menaut ke apa: root adalah satu template yang tidak ditautkan oleh template lain. Direktori yang berisi dua template tanpa tautan di antaranya tidak punya satu root, dan impor berhenti dan menyebut keduanya:
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 fromPengaturan root menyebut template tempat memulai, pada entri importer dalam konfigurasi workspace. uri menyebut importer berdasarkan identitasnya dan versi kompiler yang Anda jalankan, seperti yang ditulis aggrega plugin add importer (Importer mana yang mengubah sumber menjadi draf):
plugins: importer: - uri: importer/arm:<version> with: settings: root: site.jsonDengan root diatur, impor membaca site.json dan template yang ditautkannya, dan membiarkan network.json di luar.
Tautan yang keluar dari direktori yang diimpor — ../shared/dns.json — tidak dibaca: impor tidak pernah membuka file di luar direktori yang diberikan kepadanya. Impor memberi peringatan, menyebut resource dan path-nya, dan mendrafkan resource itu sebagai resource tersendiri, membawa setiap output template tersebut yang dibaca template sebagai ekspresi yang mengevaluasinya saat template di-deploy:
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.relativePathLetakkan template tertaut di dalam direktori yang diimpor dan impor berikutnya akan membacanya.
Saat sebuah nama sudah dipakai
Resource yang dijadikan Component oleh draf mendapat nama yang dipilih impor untuknya, dari tipenya: imported/compute/microsoft-web-staticsites untuk static web app. Jika sebuah Component dengan nama itu sudah ada di folder katalog workspace atau di hub, dan impor ini tidak mendrafkannya, impor tidak menimpanya dan tidak menebak. Impor menahan resource tersebut, tidak mendrafkan maupun merujuknya, dan memberi peringatan. Mengimpor contoh untuk kedua kalinya ke folder lain dalam workspace yang sama, dengan --output-dir second, setelah impor pertama menulis Component ke folder catalog milik workspace, menyatakan:
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 ReleasePengaturan mapping_overrides pada entri importer, dengan kunci berupa format, arm, lalu tipe resource, memetakan tipe itu ke Component yang sudah ada, dan entri yang dicetak peringatan adalah yang perlu ditulis (Pengaturan). Dengan itu, impor berikutnya merujuk Component tersebut: notes-site dipetakan sebagai referensi, dan entrinya di Release tidak memuat kunci selain komentar yang menyebut properti yang ditulis template:
notes-site: {}Component ini mendeklarasikan name dan location yang wajib, dan draf tidak menulis keduanya, sehingga impor berakhir dengan melaporkan masing-masing sebagai hilang, dengan draf yang telah ditulis. Tulis keduanya, beserta properti yang dicantumkan komentar, di Release, sebagaimana Component mendeklarasikannya.
Apa yang diserahkan draf kepada Anda
Impor mendrafkan apa yang dinyatakan template dan apa yang ditentukan katalog Anda, dan menyatakan di mana ia berhenti. Untuk sebuah template, ia menyerahkan hal-hal ini:
- Substrat yang dibuat template untuk melayani yang lain. Virtual network
vnet-notesdan subnet-nya ada di template untuk situs. Draf tidak membuat jaringan: sebuah Component dari katalog menerima jaringan tempatnya berjalan melalui resource ID-nya, di bawahinfra.overrides, dan jaringan itu milik Anda. Bariswarnmenyebut setiap resource semacam itu, dan penunjuk yang merujuknya adalah key kosong pada Release. Di tempat Release di-deploy, jaringan dan subnet sudah ada, atau Anda men-deploy-nya dengan template yang Anda impor. - Nilai yang tidak ditempatkan draf. Komentar setiap entri Release mencantumkan parameter modul dan properti resource yang tidak ditempatkan draf, di antaranya di sini tier, throughput unit, region, dan nama namespace, serta
kinddanlinuxFxVersionmilik situs, sehingga pengaturan template dinyatakan, tidak dibuang diam-diam. Jika sebuah Component punya tempat untuk salah satunya, Anda menulisnya, seperti yang dilakukan bagian Validasi. - Variabel lingkungan yang tidak dikirim koneksi mana pun.
EVENTHUB_NAMESPACEdanEVENTHUB_NAMEmilik situs disebut dalam komentar Aggregate dan Release, dan dalam satu bariswarnmasing-masing. Jika situs dikonfigurasi di Release, Anda menyetelnya di sana. - Image container. Draf membawa image hanya bila template menyatakannya dalam properti yang ditempatkan draf. Template ini menuliskannya dalam
linuxFxVersion, sehingga draf tidak membawa apa pun, dan build berhenti dengan menyebutinfra.image: image itu Anda yang menyediakan di Release.
Modul yang tidak dipetakan apa pun oleh pustaka standar disimpan utuh. Jika sebuah template men-deploy modul Azure Verified Modules dari tipe resource yang tidak dipetakan satu baris pun milik importer, impor mendrafkan sebuah Component dan sebuah Recipe yang menyumberkan modul tersebut sebagai oci://mcr.microsoft.com/bicep/<path> dengan telemetri dimatikan, dan parameter modul yang diisi oleh secret dihilangkan dan diberi peringatan. Resource dari tipe yang tidak dipetakan satu baris pun didrafkan dari template seperti halnya static web app; petunjuk pengganti pada draf menyebut aggrega import --format arm-schema, yang mendrafkan Component yang sama dari skema vendor, seperti yang dijelaskan Men-deploy layanan yang tidak dimiliki katalog.
String yang ditulis melintasi beberapa baris
JSON tidak menerima pemisah baris mentah di dalam sebuah string, dan importer membaca template sebagai JSON. Template yang memuat satu — skrip yang ditulis melintasi beberapa baris dalam nilai scriptContent — tidak dikenali, karena pembacaannya gagal:
[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)dan dengan --format arm, impor berhenti dengan menyebut tempatnya:
halt: could not parse source "main.json" as arm: json parse: invalid character '\n' in string literal at line 14, column 35Tulis setiap string dalam satu baris, dengan \n di tempat teks terputus, dan impor akan membacanya.