gpt4 book ai didi

powershell - 当前的 azure 存储不允许创建新的虚拟机

转载 作者:行者123 更新时间:2023-12-03 00:01:33 26 4
gpt4 key购买 nike

我有创建虚拟机的脚本,并通过 dsc 安装 google chrome。我创建了当前存储帐户并执行了脚本。但下次我会出错。这是我的脚本:

    $SubscriptionName = "subscription_name"
Select-AzureSubscription -SubscriptionName $SubscriptionName

#Replace the variable values as needed
$VMName = "CSETest"
$StorageAccount = 'googleChrome'
$StorageKey = 'key'
$StorageContainer = 'dscarchives'

$ServiceName="ChromeInstaller"

#Get the OS image reference
$arrayWindows=( Get-AzureVMImage | where-object { $_.ImageName -like "*Windows*Server*2012*R2*en.us*" } )

$locationAllow=$arrayWindows[$arrayWindows.Count-1].Location
$locationAllow=$locationAllow.Split(";")
$locationAllow=$locationAllow | where-object { $_ -like "* US*"}
$Localization=(Get-Random -InputObject $locationAllow)

#Create VM Config with last windows update
$vmConfig = New-AzureVMConfig -Name $VMName -ImageName $arrayWindows[$arrayWindows.Count-1].ImageName -InstanceSize Small

#Create Provisioning Configuration
$vmProvisioningConfig = Add-AzureProvisioningConfig -VM $vmConfig -Windows -AdminUsername "login" -Password "password"

$StorageContext = New-AzureStorageContext -StorageAccountName $StorageAccount -StorageAccountKey $StorageKey
Publish-AzureVMDscConfiguration -ConfigurationPath .\ChromeInstaller.ps1 -ContainerName $StorageContainer -StorageContext $StorageContext -Force

#Set the Azure VM DSC Extension to run the LCM meta-configuration
$vmAzureExtension = Set-AzureVMDscExtension -VM $vmProvisioningConfig -ConfigurationArchive ChromeInstaller.ps1.zip -ConfigurationName OpenChrome -Verbose -StorageContext $StorageContext -ContainerName $StorageContainer -Force

#Create a VM
New-AzureVM -ServiceName $ServiceName -VMs $vmAzureExtension -Location $Localization -WaitForBoot

在最后一行,脚本抛出异常:

New-AzureVM : BadRequest: The location or affinity group Central US of the storage account where the source image a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201410.01-en.us-127GB.vhd resides is not in the same location or affinity group as the specified cloud service. The source image must reside in a storage account that has the same affinity group or location as the cloud service West US.

因此,如您所见,我的脚本生成随机位置。而且我无法链接到现场。那么,我该如何修复这个错误呢?

最佳答案

源镜像 VHD 必须与新虚拟机位于同一位置。使用AzCopy将镜像复制到 $locationAllow 中列出的所有位置的存储帐户。

关于powershell - 当前的 azure 存储不允许创建新的虚拟机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26700197/

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