gpt4 book ai didi

powershell - Azure InvalidParameter : StorageProfile. dataDisks.lun 没有存储配置文件中图像所需的值

转载 作者:行者123 更新时间:2023-12-03 03:13:48 25 4
gpt4 key购买 nike

我有一个脚本可以使用 DS 系列存储在 Azure 上创建 VM。我正在尝试使用 SQL Server 优化镜像之一创建虚拟机。当我更改发布商、报价和 SKU 以匹配 SQL Server 镜像时,我不断收到错误消息:

无效参数:StorageProfile.dataDisks.lun 没有存储配置文件中图像所需的值

有谁知道我应该如何修改以下脚本,以便我可以使用 SQL Server 的预定义图像模板之一?

Switch-AzureMode AzureResourceManager

Add-AzureAccount

$subscr="subscription"
Select-AzureSubscription -SubscriptionName $subscr

$rgName="test-resource-group"
$locName="East US 2"
New-AzureResourceGroup -Name $rgName -Location $locName

$saName="testpremiumstorage"
$saType="Premium_LRS"
New-AzureStorageAccount -Name $saName -ResourceGroupName $rgName –Type $saType -Location $locName

$frontendSubnet=New-AzureVirtualNetworkSubnetConfig -Name "testfrontendSubnet" -AddressPrefix 10.3.3.0/24
$backendSubnet=New-AzureVirtualNetworkSubnetConfig -Name "testbackendSubnet" -AddressPrefix 10.3.2.0/24
New-AzurevirtualNetwork -Name "testVNet" -ResourceGroupName $rgName -Location $locName -AddressPrefix 10.3.0.0/16 -Subnet $frontendSubnet,$backendSubnet

$publicIP = New-AzurePublicIpAddress -Name "testPublicIp" -ResourceGroupName $rgName -Location $locName –AllocationMethod Static -DomainNameLabel "test-public-ip"
$frontendIP = New-AzureLoadBalancerFrontendIpConfig -Name "test-LB-Frontend" -PublicIpAddress $publicIP
$beaddresspool= New-AzureLoadBalancerBackendAddressPoolConfig -Name "test-LB-backend"
$inboundNATRule1= New-AzureLoadBalancerInboundNatRuleConfig -Name "RDP1" -FrontendIpConfiguration $frontendIP -Protocol TCP -FrontendPort 3441 -BackendPort 3389
$inboundNATRule2= New-AzureLoadBalancerInboundNatRuleConfig -Name "RDP2" -FrontendIpConfiguration $frontendIP -Protocol TCP -FrontendPort 3442 -BackendPort 3389
$healthProbe = New-AzureLoadBalancerProbeConfig -Name "HealthProbe" -RequestPath "HealthProbe.aspx" -Protocol http -Port 80 -IntervalInSeconds 15 -ProbeCount 2
$lbrule = New-AzureLoadBalancerRuleConfig -Name "HTTP" -FrontendIpConfiguration $frontendIP -BackendAddressPool $beAddressPool -Protocol Tcp -FrontendPort 80 -BackendPort 80
$NRPLB = New-AzureLoadBalancer -ResourceGroupName $rgName -Name "test-LB" -Location $locName -FrontendIpConfiguration $frontendIP -InboundNatRule $inboundNATRule1,$inboundNatRule2 -LoadBalancingRule $lbrule -BackendAddressPool $beAddressPool -Probe $healthProbe

$nicName="test-NIC"
$lbName="test-LB"
$bePoolIndex=0
$vnetName="testVNet"
$subnetIndex=0
$natRuleIndex=0
$vnet=Get-AzurevirtualNetwork -Name $vnetName -ResourceGroupName $rgName
$lb=Get-AzureLoadBalancer -Name $lbName -ResourceGroupName $rgName

$backendSubnet = Get-AzureVirtualNetworkSubnetConfig -Name "testbackendSubnet" -VirtualNetwork $vnet
$nic=New-AzureNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $locName -Subnet $backendSubnet -LoadBalancerBackendAddressPool $lb.BackendAddressPools[$bePoolIndex] -LoadBalancerInboundNatRule $lb.InboundNatRules[$natRuleIndex]

$vmName="test"
$vmSize="Standard_DS2"
$vm=New-AzureVMConfig -VMName $vmName -VMSize $vmSize

#This is where the error occurs. If it is switched to the commented image everything will work fine but not when
# trying to create the SQL Server based image
#$pubName="MicrosoftWindowsServer"
#$offerName="WindowsServer"
#$skuName="2012-R2-Datacenter"
$pubName="MicrosoftSQLServer"
$offerName="SQL2014SP1-WS2012R2"
$skuName="Enterprise-Optimized-for-OLTP"
$cred=Get-Credential -Message "Type the name and password of the local administrator account."
$vm=Set-AzureVMOperatingSystem -VM $vm -Windows -ComputerName $vmName -Credential $cred -ProvisionVMAgent -EnableAutoUpdate
$vm=Set-AzureVMSourceImage -VM $vm -PublisherName $pubName -Offer $offerName -Skus $skuName -Version "latest"
$vm=Add-AzureVMNetworkInterface -VM $vm -Id $nic.Id

$diskName="test-OSDisk"
$storageAcc=Get-AzureStorageAccount -ResourceGroupName $rgName -Name $saName
$osDiskUri=$storageAcc.PrimaryEndpoints.Blob.ToString() + "vhds/" + $diskName + ".vhd"
$vm=Set-AzureVMOSDisk -VM $vm -Name $diskName -VhdUri $osDiskUri -CreateOption fromImage
New-AzureVM -ResourceGroupName $rgName -Location $locName -VM $vm

如脚本中所述,有一个部分定义了发布商、报价和 SKU。当这些项目切换到 SQL Server 相关项目时,脚本会失败并出现错误,但如果它们使用基本的 Windows Server 2012 项目,脚本将正常运行。如果使用高级存储,项目名称是否会有所不同,或者是否有不同的方式来创建虚拟机?

最佳答案

帮助我解决类似问题的一些步骤:

  • 检查您的名字是否确实正确 - 请参阅@theadriangreen 的链接 link以及 az vm image --help 后面的列表命令
  • 检查您是否已将计划信息添加到启动中
  • 使用 az vm image Accept-terms --help 检查您是否接受条款

关于powershell - Azure InvalidParameter : StorageProfile. dataDisks.lun 没有存储配置文件中图像所需的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32659773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com