使用可信启动参数创建azure vm时出错

o7jaxewo  于 2023-11-21  发布在  其他
关注(0)|答案(1)|浏览(165)

此时此刻,同样的问题也发生在我身上:
RemoteException wrapping Microsoft.Rest.Azure.CloudException:提供的库映像仅支持创建具有“TrustedLaunch”安全类型的VM和VM缩放集。
c#代码
enter image description here

atmip9wb

atmip9wb1#

您似乎正在尝试使用仅支持“TrustedLaunch”安全类型的库映像创建VM。当您尝试创建具有不同安全类型的VM时会出现此错误,即,如果您尝试使用具有“Trusted Launch”安全类型的库映像创建VM,则会出现此错误。
根据MS Doc,如果从专用镜像版本创建VM,您会发现由于管理员用户名和密码问题,不允许使用osProfile。相反,您可以创建安全类型为Standard的VM,然后使用库镜像定义和部署VM。
以下是MS中的trusted_launch_VM列表
从门户网站,如果您要创建具有可信启动安全性的VM,请执行以下步骤-

  1. AzurePortal->VirtualMachines->CreateVirtualMachine->Choose securityType->TrustedLaunchVirtualMachine

字符串
x1c 0d1x的数据



参考文件:
Supported Gallery Images
MSDoc
MSDoc
Similar SO Thread
要使用C#创建可信启动VM,可以使用以下代码-

  1. using System;
  2. using System.Threading.Tasks;
  3. using Azure.Core;
  4. using Azure.Identity;
  5. using Azure.ResourceManager;
  6. using Azure.ResourceManager.Resources;
  7. using Azure.ResourceManager.Compute;
  8. using Azure;
  9. using Azure.ResourceManager.Compute.Models;
  10. ArmClient armClient = new ArmClient(new DefaultAzureCredential());
  11. SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();
  12. string rgName = "your-resource-group-name";
  13. ResourceGroupResource resourceGroup = await subscription.GetResourceGroups().GetAsync(rgName);
  14. VirtualMachineCollection vmCollection = resourceGroup.GetVirtualMachines();
  15. string vmName = "your-virtual-machine-name";
  16. VirtualMachineData input = new VirtualMachineData(resourceGroup.Data.Location)
  17. {
  18. HardwareProfile = new VirtualMachineHardwareProfile()
  19. {
  20. VmSize = VirtualMachineSizeType.StandardB2S
  21. },
  22. OSProfile = new VirtualMachineOSProfile()
  23. {
  24. AdminUsername = "xxx",
  25. AdminPassword = "xxx",
  26. ComputerName = "your-vm-name"
  27. },
  28. NetworkProfile = new VirtualMachineNetworkProfile()
  29. {
  30. NetworkInterfaces =
  31. {
  32. new VirtualMachineNetworkInterfaceReference()
  33. {
  34. Id = new ResourceIdentifier("/subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.Network/networkInterfaces/xxxx"),
  35. Primary = true,
  36. }
  37. }
  38. },
  39. StorageProfile = new VirtualMachineStorageProfile()
  40. {
  41. OSDisk = new VirtualMachineOSDisk(DiskCreateOptionType.FromImage)
  42. {
  43. OSType = SupportedOperatingSystemType.Windows,
  44. Caching = CachingType.ReadWrite,
  45. ManagedDisk = new VirtualMachineManagedDisk()
  46. {
  47. StorageAccountType = StorageAccountType.StandardLrs
  48. }
  49. },
  50. ImageReference = new ImageReference()
  51. {
  52. Publisher = "MicrosoftWindowsServer",
  53. Offer = "WindowsServer",
  54. Sku = "2019-datacenter-gensecond",
  55. Version = "latest",
  56. }
  57. },
  58. SecurityProfile = new SecurityProfile()
  59. {
  60. SecurityType = "TrustedLaunch",
  61. UefiSettings = new UefiSettings()
  62. {
  63. IsSecureBootEnabled = true,
  64. IsVirtualTpmEnabled = true,
  65. },
  66. EncryptionAtHost= true
  67. }
  68. };
  69. ArmOperation<VirtualMachineResource> lro = await vmCollection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, input);
  70. VirtualMachineResource vm = lro.Value


输出-

参考文档-TrustedVMusingC#

展开查看全部

相关问题