Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Artikel ini memperlihatkan kepada Anda cara menggunakan templat Azure Resource Manager (templat ARM) untuk menyebarkan ekstensi komputer virtual (VM) ke server dengan dukungan Azure Arc (komputer yang didukung Arc).
Untuk menyebarkan ekstensi ke server yang mendukung Arc dengan templat ARM, Anda menambahkan ekstensi ke dalam templat dan menjalankan proses tersebut bersamaan dengan penyebaran templat. Anda dapat menyebarkan ekstensi di komputer Linux atau Windows yang terhubung ke Azure Arc dengan menggunakan Azure PowerShell.
Artikel ini menunjukkan cara menyebarkan beberapa ekstensi VM yang berbeda ke server yang diaktifkan Arc dengan menggunakan file templat, bersama dengan file parameter terpisah untuk beberapa ekstensi. Ganti nilai contoh dalam sampel dengan nilai Anda sendiri sebelum menyebarkan.
Perintah penyebaran
Contoh perintah PowerShell ini menginstal ekstensi di semua server yang didukung Arc yang terhubung dalam grup sumber daya, berdasarkan informasi di templat ARM Anda. Perintah menggunakan TemplateFile parameter untuk menentukan templat. Jika file parameter diperlukan, TemplateParameterFile parameter disertakan untuk menentukan file yang berisi parameter dan nilai parameter. Ganti placeholder dengan nilai yang sesuai untuk deployment Anda.
Untuk menyebarkan templat ARM dan file parameter, gunakan perintah berikut, mengganti nilai contoh dengan nilai Anda sendiri:
New-AzResourceGroupDeployment -ResourceGroupName "<resource-group-name>" -TemplateFile "<template-filename.json>" -TemplateParameterFile "<parameter-filename.json>"
Contohnya:
New-AzResourceGroupDeployment -ResourceGroupName "ContosoEngineering" -TemplateFile "D:\Azure\Templates\AzureMonitorAgent.json" -TemplateParameterFile "D:\Azure\Templates\AzureMonitorAgentParams.json"
Untuk menyebarkan templat ARM tanpa file parameter, gunakan perintah berikut, mengganti nilai contoh dengan nilai Anda sendiri:
New-AzResourceGroupDeployment -ResourceGroupName "<resource-group-name>" -TemplateFile "<template-filename.json>"
Contohnya:
New-AzResourceGroupDeployment -ResourceGroupName "ContosoEngineering" -TemplateFile "D:\Azure\Templates\DependencyAgent.json"
Menyebarkan ekstensi VM Agen Azure Monitor
Untuk menyebarkan Agen Azure Monitor ke server berkemampuan Arc, gunakan salah satu templat sampel berikut untuk menginstal agen di Linux atau Windows.
Jenis sumber daya
Semua ekstensi VM server dengan dukungan Arc menggunakan jenis
Microsoft.HybridCompute/machines/extensionssumber daya (dipetakan dari jenis sumber daya ekstensi Azure VM).
File templat Agen Azure Monitor untuk Linux (server berkemampuan Arc)
Parameters
-
vmName(string, contoh:myArcMachine) -
location(string, contoh:eastus) -
workspaceId(string, contoh: ID ruang kerja Analitik Log) -
workspaceKey(string, contoh: Kunci primer Analitik Log)
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"location": {
"type": "string"
},
"workspaceId": {
"type": "string"
},
"workspaceKey": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(parameters('vmName'),'/AzureMonitorLinuxAgent')]",
"type": "Microsoft.HybridCompute/machines/extensions",
"location": "[parameters('location')]",
"apiVersion": "2025-06-01",
"properties": {
"publisher": "Microsoft.Azure.Monitor",
"type": "AzureMonitorLinuxAgent",
"enableAutomaticUpgrade": true,
"settings": {
"workspaceId": "[parameters('workspaceId')]"
},
"protectedSettings": {
"workspaceKey": "[parameters('workspaceKey')]"
}
}
}
]
}
Berkas templat Agen Azure Monitor untuk Windows (server dengan Arc diaktifkan)
Parameters
-
vmName(string, contoh:myArcMachine) -
location(string, contoh:eastus) -
workspaceId(string, contoh: ID ruang kerja Log Analitik) -
workspaceKey(string, contoh: Kunci primer Log Analitik)
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"location": {
"type": "string"
},
"workspaceId": {
"type": "string"
},
"workspaceKey": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(parameters('vmName'),'/AzureMonitorWindowsAgent')]",
"type": "Microsoft.HybridCompute/machines/extensions",
"location": "[parameters('location')]",
"apiVersion": "2025-06-01",
"properties": {
"publisher": "Microsoft.Azure.Monitor",
"type": "AzureMonitorWindowsAgent",
"autoUpgradeMinorVersion": true,
"enableAutomaticUpgrade": true,
"settings": {
"workspaceId": "[parameters('workspaceId')]"
},
"protectedSettings": {
"workspaceKey": "[parameters('workspaceKey')]"
}
}
}
]
}
File parameter Azure Monitor Agent (server yang diaktifkan Arc)
File parameter ini dapat digunakan untuk Linux dan Windows.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"value": "<vmName>"
},
"location": {
"value": "<region>"
},
"workspaceId": {
"value": "<MyWorkspaceID>"
},
"workspaceKey": {
"value": "<MyWorkspaceKey>"
}
}
}
Simpan file templat dan parameter, dan edit file parameter dengan nilai yang sesuai untuk penyebaran Anda.
Menyebarkan Agen Azure Monitor
- Prasyarat: Server yang memiliki fitur Arc terhubung dan ruang kerja Log Analytics ada.
-
Sebarkan:
New-AzResourceGroupDeployment -ResourceGroupName "<resource-group-name>" -TemplateFile "AzureMonitorAgent.json" -TemplateParameterFile "AzureMonitorAgentParams.json" - Verifikasi: Di portal Microsoft Azure, konfirmasikan status ekstensi Berhasil di server yang diaktifkan Arc.
Menyebarkan Ekstensi Skrip Kustom
Untuk menggunakan Ekstensi Skrip Kustom di server berkemampuan Arc, sebarkan salah satu templat sampel berikut untuk Linux atau Windows. Untuk informasi selengkapnya, lihat Ekstensi Skrip Kustom untuk Linux atau Ekstensi Skrip Kustom untuk Windows.
File templat ekstensi skrip kustom untuk Linux (server dengan dukungan Arc)
Parameters
-
vmName(string, contoh:myArcMachine) -
location(string, contoh:eastus) -
fileUris(array, contoh: URL skrip) -
commandToExecute(securestring, contoh:sh script.sh)
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"location": {
"type": "string"
},
"fileUris": {
"type": "array"
},
"commandToExecute": {
"type": "securestring"
}
},
"resources": [
{
"name": "[concat(parameters('vmName'),'/CustomScript')]",
"type": "Microsoft.HybridCompute/machines/extensions",
"location": "[parameters('location')]",
"apiVersion": "2025-06-01",
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"autoUpgradeMinorVersion": true,
"settings": {},
"protectedSettings": {
"commandToExecute": "[parameters('commandToExecute')]",
"fileUris": "[parameters('fileUris')]"
}
}
}
]
}
File templat skrip kustom untuk Windows (server dengan dukungan Arc)
Parameters
-
vmName(string, contoh:myArcMachine) -
location(string, contoh:eastus) -
fileUris(string, contoh: URL skrip) -
arguments(securestring, opsional, contoh:-Param1 Value1)
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"location": {
"type": "string"
},
"fileUris": {
"type": "string"
},
"arguments": {
"type": "securestring",
"defaultValue": " "
}
},
"variables": {
"UriFileNamePieces": "[split(parameters('fileUris'), '/')]",
"firstFileNameString": "[variables('UriFileNamePieces')[sub(length(variables('UriFileNamePieces')), 1)]]",
"firstFileNameBreakString": "[split(variables('firstFileNameString'), '?')]",
"firstFileName": "[variables('firstFileNameBreakString')[0]]"
},
"resources": [
{
"name": "[concat(parameters('vmName'),'/CustomScriptExtension')]",
"type": "Microsoft.HybridCompute/machines/extensions",
"location": "[parameters('location')]",
"apiVersion": "2022-03-10",
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": "[split(parameters('fileUris'), ' ')]"
},
"protectedSettings": {
"commandToExecute": "[concat ('powershell -ExecutionPolicy Unrestricted -File ', variables('firstFileName'), ' ', parameters('arguments'))]"
}
}
}
]
}
Menyebarkan Ekstensi Skrip Kustom
- Prasyarat: File skrip dapat diakses dari server yang didukung Arc.
-
Sebarkan:
New-AzResourceGroupDeployment -ResourceGroupName "<resource-group-name>" -TemplateFile "CustomScript.json"
Menyebarkan ekstensi Agen Dependensi
Gunakan templat berikut untuk menyebarkan Agen Dependensi ke komputer Linux atau Windows dengan dukungan Arc.
File templat Agen Dependensi untuk Linux (server berkemampuan Arc)
Parameters
-
vmName(string, contoh:myArcMachine)
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
}
},
"resources": [
{
"type": "Microsoft.HybridCompute/machines/extensions",
"name": "[concat(parameters('vmName'),'/DAExtension')]",
"apiVersion": "2025-06-01",
"location": "[resourceGroup().location]",
"properties": {
"publisher": "Microsoft.Azure.Monitoring.DependencyAgent",
"type": "DependencyAgentLinux",
"enableAutomaticUpgrade": true
}
}
]
}
File templat Agen Dependensi untuk Windows (server berkemampuan Arc)
Parameters
-
vmName(string, contoh:myArcMachine)
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string",
"metadata": {
"description": "The name of existing Windows machine."
}
}
},
"resources": [
{
"type": "Microsoft.HybridCompute/machines/extensions",
"name": "[concat(parameters('vmName'),'/DAExtension')]",
"apiVersion": "2022-03-10",
"location": "[resourceGroup().location]",
"dependsOn": [
],
"properties": {
"publisher": "Microsoft.Azure.Monitoring.DependencyAgent",
"type": "DependencyAgentWindows",
"enableAutomaticUpgrade": true
}
}
],
"outputs": {
}
}
Menyebarkan Agen Dependensi
- Prasyarat: Azure Monitor diaktifkan untuk server berkemampuan Arc.
-
Sebarkan:
New-AzResourceGroupDeployment -ResourceGroupName "<resource-group-name>" -TemplateFile "DependencyAgent.json" - Verifikasi: Di portal Microsoft Azure, konfirmasikan status ekstensi Berhasil di server yang diaktifkan Arc.
Menyebarkan ekstensi Azure Key Vault
JSON berikut menunjukkan skema untuk ekstensi Azure Key Vault. Ekstensi ini tidak memerlukan pengaturan yang dilindungi, karena semua pengaturannya dianggap sebagai informasi publik. Ekstensi ini memerlukan daftar sertifikat yang dipantau, frekuensi polling, dan penyimpanan sertifikat tujuan.
File templat Azure Key Vault untuk Linux (server dengan dukungan Arc)
Parameters
-
vmName(string, contoh:myArcMachine) -
location(string, contoh:eastus) -
autoUpgradeMinorVersion(bool, contoh:true) -
pollingIntervalInS(int, contoh:3600) -
certificateStoreName(string, diabaikan di Linux) -
certificateStoreLocation(string, contoh:/var/lib/waagent/Microsoft.Azure.KeyVault) -
observedCertificates(string, contoh: URI sertifikat Key Vault) -
msiEndpoint(string, contoh:http://localhost:40342/metadata/identity) -
msiClientId(string, contoh: ID klien identitas terkelola)
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"location": {
"type": "string"
},
"autoUpgradeMinorVersion":{
"type": "bool"
},
"pollingIntervalInS":{
"type": "int"
},
"certificateStoreName":{
"type": "string"
},
"certificateStoreLocation":{
"type": "string"
},
"observedCertificates":{
"type": "string"
},
"msiEndpoint":{
"type": "string"
},
"msiClientId":{
"type": "string"
}
},
"resources": [
{
"type": "Microsoft.HybridCompute/machines/extensions",
"name": "[concat(parameters('vmName'),'/KVVMExtensionForLinux')]",
"apiVersion": "2022-03-10",
"location": "[parameters('location')]",
"properties": {
"publisher": "Microsoft.Azure.KeyVault",
"type": "KeyVaultForLinux",
"enableAutomaticUpgrade": true,
"settings": {
"secretsManagementSettings": {
"pollingIntervalInS": <polling interval in seconds, e.g. "3600">,
"certificateStoreName": <ignored on linux>,
"certificateStoreLocation": <disk path where certificate is stored, default: "/var/lib/waagent/Microsoft.Azure.KeyVault">,
"observedCertificates": <list of KeyVault URIs representing monitored certificates, e.g.: "https://myvault.vault.azure.net/secrets/mycertificate"
},
"authenticationSettings": {
"msiEndpoint": "http://localhost:40342/metadata/identity"
}
}
}
}
]
}
File templat Azure Key Vault untuk Windows (server yang diaktifkan dengan Arc)
Parameters
-
vmName(string, contoh:myArcMachine) -
location(string, contoh:eastus) -
autoUpgradeMinorVersion(bool, contoh:true) -
pollingIntervalInS(int, contoh:3600) -
certificateStoreName(string, contoh:MY) -
linkOnRenewal(bool, contoh:false) -
certificateStoreLocation(string, contoh:LocalMachine) -
requireInitialSync(bool, contoh:true) -
observedCertificates(string, contoh: URI sertifikat Key Vault) -
msiEndpoint(string, contoh:http://localhost:40342/metadata/identity) -
msiClientId(string, contoh: ID klien identitas terkelola)
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"location": {
"type": "string"
},
"autoUpgradeMinorVersion":{
"type": "bool"
},
"pollingIntervalInS":{
"type": "int"
},
"certificateStoreName":{
"type": "string"
},
"linkOnRenewal":{
"type": "bool"
},
"certificateStoreLocation":{
"type": "string"
},
"requireInitialSync":{
"type": "bool"
},
"observedCertificates":{
"type": "string"
},
"msiEndpoint":{
"type": "string"
},
"msiClientId":{
"type": "string"
}
},
"resources": [
{
"type": "Microsoft.HybridCompute/machines/extensions",
"name": "[concat(parameters('vmName'),'/KVVMExtensionForWindows')]",
"apiVersion": "2022-03-10",
"location": "[parameters('location')]",
"properties": {
"publisher": "Microsoft.Azure.KeyVault",
"type": "KeyVaultForWindows",
"enableAutomaticUpgrade": true,
"settings": {
"secretsManagementSettings": {
"pollingIntervalInS": "3600",
"certificateStoreName": <certificate store name, e.g.: "MY">,
"linkOnRenewal": <Only Windows. This feature ensures s-channel binding when certificate renews, without necessitating a re-deployment. e.g.: false>,
"certificateStoreLocation": <certificate store location, currently it works locally only e.g.: "LocalMachine">,
"requireInitialSync": <initial synchronization of certificates e.g.: true>,
"observedCertificates": <list of KeyVault URIs representing monitored certificates, e.g.: "https://myvault.vault.azure.net"
},
"authenticationSettings": {
"msiEndpoint": "http://localhost:40342/metadata/identity"
}
}
}
}
]
}
Catatan
URL sertifikat yang Anda amati harus dalam bentuk https://myVaultName.vault.azure.net/secrets/myCertName. Alasannya adalah bahwa /secrets jalur mengembalikan sertifikat lengkap, termasuk kunci privat, sedangkan /certificates jalurnya tidak. Untuk informasi selengkapnya tentang sertifikat, lihat Gambaran umum kunci, rahasia, dan sertifikat Azure Key Vault.
Simpan templat dan edit sesuai kebutuhan untuk lingkungan Anda. Kemudian instal ekstensi Azure Key Vault ke komputer yang terhubung dengan menjalankan perintah penyebaran PowerShell yang ditemukan sebelumnya di artikel ini.
Petunjuk / Saran
Ekstensi Azure Key Vault memerlukan identitas yang ditetapkan sistem untuk mengautentikasi ke Key Vault. Untuk informasi selengkapnya, lihat Mengautentikasi terhadap sumber daya Azure dengan server dengan dukungan Azure Arc.
Konten terkait
- Baca selengkapnya tentang ekstensi VM yang didukung oleh server dengan dukungan Azure Arc.
- Pelajari cara menyebarkan, mengelola, dan menghapus ekstensi VM dengan menggunakan Azure PowerShell, portal Microsoft Azure, atau Azure CLI.
- Jelajahi informasi pemecahan masalah dalam panduan untuk memecahkan masalah ekstensi VM.