Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.24k stars 3.84k forks source link

New-AzureRMDisk cmdlet says it is missing a Location on any invocation after Add-AzureRMVMDataDisk is run #4419

Closed iaingblack closed 6 years ago

iaingblack commented 7 years ago

Cmdlet(s)

New-AzureRmDiskConfig and New-AzureRmDisk

PowerShell Version

5.0.10586.117

Module Version

4.2.1

OS Version

10.0.10586.117

Description

Adding a disk to a VM works first time, but subsequent calls fail.

Debug Output

Nothing extra interesting happens, simply gets a login token

Script/Steps for Reproduction

Run these commands (assuming existing VM and storage container)

$vm = Get-AzureRmVM -ResourceGroupName $resourceGroupName -Name "$($VMNamePrefix)A1"
$diskConfig = New-AzureRmDiskConfig -AccountType $diskStorageAccountType -Location $resourceGroupLocation -OsType Windows -CreateOption Empty -DiskSizeGB $appDataDiskSize
$disk = New-AzureRmDisk -DiskName $appDataDiskName -Disk $diskConfig -ResourceGroupName $resourceGroupName
Add-AzureRmVMDataDisk -VM $vm -Name $appDataDiskName  -CreateOption Attach -ManagedDiskId $disk.Id -Lun 0
Update-AzureRmVM -VM $vm -ResourceGroupName $resourceGroupName

This works. Then run something similar to add a disk to another or same VM fails as it is missing a location. But, location is not a parameter on New-AzureRMDisk and is supplied on the New-AzureRMDiskConfig.

$vm = Get-AzureRmVM -ResourceGroupName $resourceGroupName -Name "$($VMNamePrefix)S1"
$diskConfig = New-AzureRmDiskConfig -AccountType $diskStorageAccountType -Location $resourceGroupLocation -OsType Windows -CreateOption Empty -DiskSizeGB $sqlDataDiskSize
$disk = New-AzureRMDisk -DiskName $sqlDataDiskName -Disk $diskConfig -ResourceGroupName $resourceGroupName

FAILS HERE WHEN CREATING New-AzureRMDisk

New-AzureRmDisk : 'Location' cannot be null.
At line:1 char:9
+ $disk = New-AzureRmDisk -DiskName $sqlLogDiskName -Disk $diskConfig - ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmDisk], ValidationException
    + FullyQualifiedErrorId : Microsoft.Rest.ValidationException,Microsoft.Azure.Commands.Compute.Automation.NewAzureR
   mDisk

I tried blanking variables etc... But, only solution I found was a new console sessions and doing for each disk required. Not workable really. Thanks!

mbenko commented 7 years ago

I am seeing the same.

cormacpayne commented 7 years ago

@hyonholee @singhkays would you mind taking a look at this issue?

singhkays commented 7 years ago

Just tried it with the latest PS 4.3.0 and it's worked fine. Can you try with the latest bits?

PS C:\Users\kasing> $diskConfig = New-AzureRmDiskConfig -AccountType "StandardLRS" -Location "West US 2" -CreateOption Import -SourceUri "https://abcd9374.blob.core.windows.net/vhds/osdiskforlinuxsimple.vhd" -OsType Linux 
New-AzureRmDisk -DiskName osdiskforlinuxsimple -Disk $diskConfig -ResourceGroupName "abcd"

ResourceGroupName  : abcd
AccountType        : StandardLRS
OwnerId            : 
ManagedBy          : 
Sku                : Microsoft.Azure.Management.Compute.Models.DiskSku
TimeCreated        : 8/11/2017 11:05:01 AM
OsType             : Linux
CreationData       : Microsoft.Azure.Management.Compute.Models.CreationData
DiskSizeGB         : 
EncryptionSettings : 
ProvisioningState  : Succeeded
Id                 : /subscriptions/***/resourceGroups/abcd/providers/Microsoft.Compute/disks/osdiskforlinuxsimple
Name               : osdiskforlinuxsimple
Type               : Microsoft.Compute/disks
Location           : westus2
Tags               : {}
j4y-k commented 7 years ago

Same issue here with -Location being 'null'. PS ver 4.0 and AzureRM.Profile ver 3.2.1

singhkays commented 7 years ago

@j4y-k Please try with the latest version and see if you still run into this

mbenko commented 7 years ago

I found that I could call New-AzureRmDisk multiple times successfully until I call Add-AzureRmDataDisk, after which subsequent calls to New-AzureRmDisk fail with the -Location error. To work around it I have to close and restart PowerShell ISE.

My workaround currently is to call New-AzureRMDisk for all the disks I'll need, then call Add-AzureRmDataDisk for each (that works), and then update the VM and close the session.

pierreroman commented 7 years ago

updated my powershell modules this morning:

ModuleType Version Name


Manifest 3.2.1 AzureRM.Compute Manifest 4.2.1 AzureRM.Network Manifest 3.2.1 AzureRM.Profile Manifest 4.2.1 AzureRM.Resources Script 1.0.0.0 ISE Manifest 3.1.0.0 Microsoft.PowerShell.Management Manifest 3.0.0.0 Microsoft.PowerShell.Security Manifest 3.1.0.0 Microsoft.PowerShell.Utility
Manifest 3.0.0.0 Microsoft.WSMan.Management

Name Value


PSVersion 5.1.15063.502
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.502
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

still getting the error. New-AzureRmDisk : 'Location' cannot be null. At C:\Users\pierrer\Documents\Github\Igloo-POC\PSFiles\Deploy-VM-template.ps1:124 char:26

pierreroman commented 7 years ago

where can i find the MSI for the azure modules that where available before azure-powershell.4.2.1.msi was released? that seems to be the build that broke the cmdlets

singhkays commented 7 years ago

@pierreroman The latest PS release is now live. Please update through WebPi and try again.

cormacpayne commented 6 years ago

Closing as this issue seems to be fixed. Please feel free to re-open this issue if this is not the case.