使用 CLI 建立 VM,如下所示:
$vmName="<Name of the VM>"
$subscription="<Subscription ID associated with your Azure Local system>"
$resourceGroup="<Resource group name for your Azure Local system>"
$location="<Location for your Azure Local system>"
$customLocationID=(az customlocation show --resource-group $resource_group --name "<custom location name for your Azure Local system>" --query id -o tsv)
$guestName="<Name of the guest>"
$userName="<Username for VM>"
$password="<Password for VM>"
$galleryImageName="<Name of VM guest image>"
$vNic="<Name of virtual network interface>"
az stack-hci-vm create --name $vmName --subscription $subscription --resource-group $resourceGroup --custom-location=$customLocationID --location $location --size="Default" --computer-name $guestName --admin-username $userName --admin-password $password --image $galleryImageName --nics $vNic --enable-secure-boot true --enable-vtpm true --security-type "TrustedLaunch"
範例輸出:
{
"extendedLocation": {
"name": "/subscriptions/myhci-sub/resourceGroups/myhci-rg/Microsoft.ExtendedLocation/customLocations/myhci-cl",
"type": "CustomLocation"
},
"id": "/subscriptions/myhci-sub/resourceGroups/myhci-rg/providers/Microsoft.HybridCompute/machines/tvm1/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default",
"name": "default",
"properties": {
"hardwareProfile": {
"dynamicMemoryConfig": {
"maximumMemoryMb": null,
"minimumMemoryMb": null,
"targetMemoryBuffer": null
},
"memoryMb": 4096,
"processors": 4,
"vmSize": "Custom"
},
"instanceView": {
"vmAgent": {
"statuses": []
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "ram-nic"
}
]
},
"osProfile": {
"adminPassword": null,
"adminUsername": "admin",
"computerName": "myhci-tvm",
"linuxConfiguration": {
"disablePasswordAuthentication": null,
"provisionVmAgent": false,
"provisionVmConfigAgent": false,
"ssh": {
"publicKeys": null
}
},
"windowsConfiguration": {
"enableAutomaticUpdates": null,
"provisionVmAgent": false,
"provisionVmConfigAgent": false,
"ssh": {
"publicKeys": null
},
"timeZone": null
}
},
"provisioningState": "Succeeded",
"securityProfile": {
"enableTpm": true,
"securityType": "TrustedLaunch",
"uefiSettings": {
"secureBootEnabled": true
}
},
"status": {
"powerState": "Running"
},
"storageProfile": {
"dataDisks": [],
"imageReference": {
"id": "/subscriptions/myhci-sub/resourceGroups/myhci-rg/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/Win11EntMulti21H2",
"resourceGroup": "myhci-rg"
},
"osDisk": {
"id": null,
"osType": "Windows"
},
"storagepathId": null
},
"vmId": "myhci-tvm-1234567890"
},
"resourceGroup": "myhci-rg",
"systemData": {
"createdAt": "2023-10-24T19:15:47.152610+00:00",
"createdBy": "registration@contoso.com",
"createdByType": "User",
"lastModifiedAt": "2023-10-24T19:41:05.196469+00:00",
"lastModifiedBy": "319f651f-7ddb-4fc6-9857-7aef9250bd05",
"lastModifiedByType": "Application"
},
"tags": null,
"type": "microsoft.azurestackhci/virtualmachineinstances"
}