Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This sample shows how to add a new data disk to a VM in Azure via PowerShell. The sample demonstrates an error based on an unset default storage account.
Get-AzureSubscription -SubscriptionName "Azure MSDN - pkirchner"
<# Output
SubscriptionId : c6264819-a8d6-4279-b493-4a47f4300c54
SubscriptionName : Azure MSDN - pkirchner
Environment : AzureCloud
SupportedModes : AzureServiceManagement
DefaultAccount : BE130E17300A9E2F90B1A0575557266671623B04
Accounts : {BE130E17300A9E2F90B1A0575557266671623B04}
IsDefault : True
IsCurrent : True
CurrentStorageAccountName :
#>
Get-AzureVM -ServiceName leasetest2 -Name host2 | Add-AzureDataDisk -CreateNew -DiskLabel "DataDisk2" -DiskSizeInGB 1023 -LUN 0 -HostCaching ReadWrite | Update-AzureVM
<# Output
Add-AzureDataDisk : Must specify MediaLocation or set a default storage account using Set-AzureSubscription.
In Zeile:1 Zeichen:51
+ Get-AzureVM -ServiceName leasetest2 -Name host2 | Add-AzureDataDisk -CreateNew - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzureDataDisk], ArgumentException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.AddAzureDataDiskCommand
#>
Get-AzureStorageAccount
<# Output
StorageAccountDescription :
AffinityGroup :
Location : West Europe
GeoReplicationEnabled :
GeoPrimaryLocation : West Europe
GeoSecondaryLocation :
Label : pktest1
StorageAccountStatus : Created
StatusOfPrimary : Available
StatusOfSecondary :
Endpoints : {https://pktest1.blob.core.windows.net/, https://pktest1.queue.core.windows.net/,
https://pktest1.table.core.windows.net/, https://pktest1.file.core.windows.net/}
AccountType : Standard_LRS
StorageAccountName : pktest1
OperationDescription : Get-AzureStorageAccount
OperationId : db4c00ce-ed1c-5351-8de7-1b595419a5dc
OperationStatus : Succeeded
WARNUNG: GeoReplicationEnabled property will be deprecated in a future release of Azure PowerShell. The value will be merged into the AccountType pr
operty.
#>
Set-AzureSubscription -SubscriptionName "Azure MSDN - pkirchner" -CurrentStorageAccountName pktest1
Get-AzureVM -ServiceName leasetest2 -Name host2 | Add-AzureDataDisk -CreateNew -DiskLabel "DataDisk2" -DiskSizeInGB 1023 -LUN 0 -HostCaching ReadWrite | Update-AzureVM
<# Output
OperationDescription OperationId OperationStatus
-------------------- ----------- ---------------
Update-AzureVM c2187124-547c-55c3-a0ef-0129474e02b9 Succeeded
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.