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

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

此时此刻,同样的问题也发生在我身上:
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,请执行以下步骤-

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

字符串
x1c 0d1x的数据



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

using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Compute;
using Azure;
using Azure.ResourceManager.Compute.Models;

ArmClient armClient = new ArmClient(new DefaultAzureCredential());
SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();

string rgName = "your-resource-group-name";
ResourceGroupResource resourceGroup = await subscription.GetResourceGroups().GetAsync(rgName);
VirtualMachineCollection vmCollection = resourceGroup.GetVirtualMachines();
string vmName = "your-virtual-machine-name";
VirtualMachineData input = new VirtualMachineData(resourceGroup.Data.Location)
{
   HardwareProfile = new VirtualMachineHardwareProfile()
   {
       VmSize = VirtualMachineSizeType.StandardB2S
   },
   OSProfile = new VirtualMachineOSProfile()
   {
       AdminUsername = "xxx",
       AdminPassword = "xxx",
       ComputerName = "your-vm-name"

   },
   NetworkProfile = new VirtualMachineNetworkProfile()
   {
       NetworkInterfaces =
       {
           new VirtualMachineNetworkInterfaceReference()
           {
               Id = new ResourceIdentifier("/subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.Network/networkInterfaces/xxxx"),
               Primary = true,
           }
       }
   },
   StorageProfile = new VirtualMachineStorageProfile()
   {
       OSDisk = new VirtualMachineOSDisk(DiskCreateOptionType.FromImage)
       {
           OSType = SupportedOperatingSystemType.Windows,
           Caching = CachingType.ReadWrite,
           ManagedDisk = new VirtualMachineManagedDisk()
           {
               StorageAccountType = StorageAccountType.StandardLrs
           }
       },
       ImageReference = new ImageReference()
       {
           Publisher = "MicrosoftWindowsServer",
           Offer = "WindowsServer",
           Sku = "2019-datacenter-gensecond",
           Version = "latest",
       }
   },
   SecurityProfile = new SecurityProfile()
   {
       SecurityType = "TrustedLaunch",
       UefiSettings = new UefiSettings()
       {
           IsSecureBootEnabled = true,
           IsVirtualTpmEnabled = true,
       },
       EncryptionAtHost= true
   }
};
ArmOperation<VirtualMachineResource> lro = await vmCollection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, input);
VirtualMachineResource vm = lro.Value


输出-

参考文档-TrustedVMusingC#

相关问题