我正在尝试使用以下PowerShell脚本将磁盘添加到Azure中的VM:
$rgName = "${resourceManager}"
$stName = "${storageAccount}"
$diskname="${diskName}"
$lun = ${lunNum}
$vmName = "${vmName}"
$diskSize=${diskSize}
$storageAcc=Get-AzureRmStorageAccount -ResourceGroupName $rgName -Name $stName
$diskpath=$storageAcc.PrimaryEndpoints.Blob.ToString() + "vhds/" + $diskname + ".vhd"
$vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName | Add-AzureRmVMDataDisk -Name $diskname -VhdUri $diskpath -CreateOption empty -DiskSizeInGB $diskSize -Lun $lun
$vm.Tags = $null
$vm | Update-AzureRmVM
以下是我需要的值的描述:
SubscriptionID - Azure Subscription ID
AzureUsername - Name of Azure service account. It must be configured as co-administrator on the Azure Subscription
AzurePassword - Associated Azure service account password
resourceManager - Name of Resource Manager (RM) containing the VM
storageAccount - Name of storage account (within the specified RM), where to create the new disk
diskName - desired name of the disk
diskSize - desired size of the disk in Giga Bytes, this is a quota, up to 1000 GB is allowed
lunNum - the lun number to use, valid values are 0,1,2,3, etc.
vmName - the name of an existing VM where to attach the new disk
以下是我在脚本中使用的测试值:
SubscriptionID - 06e2bb3d-e66d-4a21-a4a0-78b2fe53f8c6
AzureUsername – test@outlook.com
AzurePassword – test123
resourceManager –
storageAccount -
diskName - test
diskSize - 100
lunNum -
vmName - ALPHABETTVM001
我不确定在哪里获得resourceManager,storageAccount和lunNum输入。我正在功能测试已从旧ASM转换为新ARM模型的Azure脚本,但我对此没有太多经验。我在哪里可以找到给定虚拟机的这三个值?
答案 0 :(得分:1)
在Azure资源模块(ARM,new)中,我们可以使用Login-AzureRmAccount通过PowerShell登录Azure。
我不确定在哪里购买resourceManager,storageAccount和 lunNum输入。
您可以通过PowerShell登录Azure,并列出所有资源组名称:
$ rgName =“资源组名称”
Get-AzureRmResourceGroup | select resourcegroupname
ResourceGroupName
-----------------
Api-Default-North-Central-US
AppResource
CS-WebJobs-NorthCentralUS-scheduler
Default-ApplicationInsights-CentralUS
Default-Networking
Default-ServiceBus-CentralUS
Default-SQL-CentralUS
Default-Storage-EastUS
Default-Web-NorthCentralUS
DemoVS8172016
DennisSPMonitor
lb1
win
您还可以使用新门户查找资源组:
关于存储帐户,我们可以使用PowerShell列出资源组中的所有存储帐户(您也可以通过新门户找到存储帐户名称):
Get-AzureRmStorageAccount -ResourceGroupName win | select storageaccountname
StorageAccountName
------------------
windiag865 (used for log)
windisks548 (used for data)
关于 lunnum ,如果您的VM只有一个没有数据磁盘的操作系统磁盘,默认情况下第一个lunnum为0,在向VM添加数据磁盘后,您可以使用PowerShell列出Lun号:
get-azurermvm -ResourceGroupName "win" -Name "win"
StorageProfile :
ImageReference :
Publisher : MicrosoftWindowsServer
Offer : WindowsServer
Sku : 2012-R2-Datacenter
Version : latest
OsDisk :
OsType : Windows
Name : win
Vhd :
Uri : https://windisks548.blob.core.windows.net/vhds/win20170111102348.vhd
Caching : ReadWrite
CreateOption : FromImage
DataDisks[0] :
Lun : 0
Name : win-20170111-103800
Vhd :
Uri : https://windisks548.blob.core.windows.net/vhds/win-20170111-103800.vhd
Caching : None
CreateOption : Empty
DiskSizeGB : 50
DataDiskNames[0] : win-20170111-103800
PS > (get-azurermvm -ResourceGroupName "win" -Name "win").StorageProfile.DataDisks.lun
0