Can I upgrade a managed disk used by an Azure VM without having to redeploy the VM?My Linux Azure server hangs and it takes lots of time to rebootRecreate Azure virtual machine from existing and working diskSlow disk performance on Azure Virtual MachineConfiguring/Fixing SSH Access on a CentOS 7.2 Box in Azureis it possible to use azure managed disks with azure scale sets, as an OS diskHDD on a S Type VM AzureAttatching a P6 x 2 Managed Disk to my Azure VM MachineNeed to upgrade Azure VM Standard HDD to SSD?Azure Disk Encryption without Azure ADDoes an Azure Backup of a VM bump users off the system during execution?

Is there a word for returning to unpreparedness?

Can anybody tell me who this Pokemon is?

What happens when a person with some edited genetics (like say, eagle eyes) reproduces with a person with regular genetics?

"sh -c" does not expand positional parameters, if I run it from "sudo --login". Is there a way around this?

How to gracefully leave a company you helped start?

Output with the same length always

String routines

A Magic Diamond

What exactly happened to the 18 crew members who were reported as "missing" in "Q Who"?

Would getting a natural 20 with a penalty still count as a critical hit?

When does The Truman Show take place?

What does 〇〇〇〇 mean when combined with おじさん?

Doesn't the speed of light limit imply the same electron can be annihilated twice?

Did Michelle Obama have a staff of 23; and Melania have a staff of 4?

Unsolved Problems due to Lack of Computational Power

What should I do with the stock I own if I anticipate there will be a recession?

Is this really better analyzed in G minor than in Bb?

Is Fourier series a sampled version of Fourier transform?

Attacking the Hydra

What are the advantages of this gold finger shape?

Why is su world executable?

Is there a way, other than having a Diviner friend, for a player to avoid rolling Initiative at the start of a combat?

What are some tips and tricks for finding the cheapest flight when luggage and other fees are not revealed until far into the booking process?

Heyawacky: Ace of Cups



Can I upgrade a managed disk used by an Azure VM without having to redeploy the VM?


My Linux Azure server hangs and it takes lots of time to rebootRecreate Azure virtual machine from existing and working diskSlow disk performance on Azure Virtual MachineConfiguring/Fixing SSH Access on a CentOS 7.2 Box in Azureis it possible to use azure managed disks with azure scale sets, as an OS diskHDD on a S Type VM AzureAttatching a P6 x 2 Managed Disk to my Azure VM MachineNeed to upgrade Azure VM Standard HDD to SSD?Azure Disk Encryption without Azure ADDoes an Azure Backup of a VM bump users off the system during execution?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








5















I'm trying to convert a separate managed disk I added to my Windows 2019 Server VM from Standard SSD to a Premium SSD. According to the steps at https://docs.microsoft.com/bs-latn-ba/Azure/virtual-machines/windows/convert-disk-storage, I'll have to stop the VM to perform this--but I'm afraid that if I stop it, there will be a ripple effect that will delay my team's ability to get back online and keep working right away. One specific scenario I'm trying to avoid is a mandatory redeployment of the VM.



See, I have third-party software running on this Azure VM and its software licensing module (SLM) might need to be reset/reinitialized if the VM gets redeployed. That re-initialization can be a lengthy process because I've got to get on the phone with tech support, request the help, get rerouted who knows how many times, and wait for the reissued license, apply the new license, and test that everything is back to normal. It's something I'm trying to avoid because it might make my team lose a day's worth of work while I get the software manufacturer to reissue/reconfigure my SLM. The SLM relies on the CPUID and MAC ID of its host computer. Since a redeployment implies that the virtual machine may get deployed on a different physical piece of hardware, I would most likely need the SLM reset. I don't want that.



So my questions are,



  • If I shut down the VM for maintenance (such as upgrading an external managed disk from Standard SSD to Premium SSD, for instance), will that force a redeploy?


  • Is a shut down effectively the same as hitting Stop for that VM on the Azure portal?


  • I hear there's a Stop and a separate Stop/Redeploy option, but if so, I don't immediately see that. Is that Redeploy an option I'll see after I hit Stop?










share|improve this question
























  • I managed to experiment with a separate dummy VM and clicked Stop. The Azure portal immediately warned me that I risked losing the machine's Public IP Address, but gave me the option to reserve it. I told it to go ahead with the Stop regardless because I didn't care about this particular dummy IP. But then I saw that the status of the VM went to "Deallocating". I never got a prompt about whether I wanted to redeploy it. Ooh! Not good news for me! Doesn't a deallocation automatically imply that the next time I restart the VM, it will necessarily be redeployed on potentially different hardware?

    – ShieldOfSalvation
    Aug 5 at 4:23


















5















I'm trying to convert a separate managed disk I added to my Windows 2019 Server VM from Standard SSD to a Premium SSD. According to the steps at https://docs.microsoft.com/bs-latn-ba/Azure/virtual-machines/windows/convert-disk-storage, I'll have to stop the VM to perform this--but I'm afraid that if I stop it, there will be a ripple effect that will delay my team's ability to get back online and keep working right away. One specific scenario I'm trying to avoid is a mandatory redeployment of the VM.



See, I have third-party software running on this Azure VM and its software licensing module (SLM) might need to be reset/reinitialized if the VM gets redeployed. That re-initialization can be a lengthy process because I've got to get on the phone with tech support, request the help, get rerouted who knows how many times, and wait for the reissued license, apply the new license, and test that everything is back to normal. It's something I'm trying to avoid because it might make my team lose a day's worth of work while I get the software manufacturer to reissue/reconfigure my SLM. The SLM relies on the CPUID and MAC ID of its host computer. Since a redeployment implies that the virtual machine may get deployed on a different physical piece of hardware, I would most likely need the SLM reset. I don't want that.



So my questions are,



  • If I shut down the VM for maintenance (such as upgrading an external managed disk from Standard SSD to Premium SSD, for instance), will that force a redeploy?


  • Is a shut down effectively the same as hitting Stop for that VM on the Azure portal?


  • I hear there's a Stop and a separate Stop/Redeploy option, but if so, I don't immediately see that. Is that Redeploy an option I'll see after I hit Stop?










share|improve this question
























  • I managed to experiment with a separate dummy VM and clicked Stop. The Azure portal immediately warned me that I risked losing the machine's Public IP Address, but gave me the option to reserve it. I told it to go ahead with the Stop regardless because I didn't care about this particular dummy IP. But then I saw that the status of the VM went to "Deallocating". I never got a prompt about whether I wanted to redeploy it. Ooh! Not good news for me! Doesn't a deallocation automatically imply that the next time I restart the VM, it will necessarily be redeployed on potentially different hardware?

    – ShieldOfSalvation
    Aug 5 at 4:23














5












5








5


1






I'm trying to convert a separate managed disk I added to my Windows 2019 Server VM from Standard SSD to a Premium SSD. According to the steps at https://docs.microsoft.com/bs-latn-ba/Azure/virtual-machines/windows/convert-disk-storage, I'll have to stop the VM to perform this--but I'm afraid that if I stop it, there will be a ripple effect that will delay my team's ability to get back online and keep working right away. One specific scenario I'm trying to avoid is a mandatory redeployment of the VM.



See, I have third-party software running on this Azure VM and its software licensing module (SLM) might need to be reset/reinitialized if the VM gets redeployed. That re-initialization can be a lengthy process because I've got to get on the phone with tech support, request the help, get rerouted who knows how many times, and wait for the reissued license, apply the new license, and test that everything is back to normal. It's something I'm trying to avoid because it might make my team lose a day's worth of work while I get the software manufacturer to reissue/reconfigure my SLM. The SLM relies on the CPUID and MAC ID of its host computer. Since a redeployment implies that the virtual machine may get deployed on a different physical piece of hardware, I would most likely need the SLM reset. I don't want that.



So my questions are,



  • If I shut down the VM for maintenance (such as upgrading an external managed disk from Standard SSD to Premium SSD, for instance), will that force a redeploy?


  • Is a shut down effectively the same as hitting Stop for that VM on the Azure portal?


  • I hear there's a Stop and a separate Stop/Redeploy option, but if so, I don't immediately see that. Is that Redeploy an option I'll see after I hit Stop?










share|improve this question














I'm trying to convert a separate managed disk I added to my Windows 2019 Server VM from Standard SSD to a Premium SSD. According to the steps at https://docs.microsoft.com/bs-latn-ba/Azure/virtual-machines/windows/convert-disk-storage, I'll have to stop the VM to perform this--but I'm afraid that if I stop it, there will be a ripple effect that will delay my team's ability to get back online and keep working right away. One specific scenario I'm trying to avoid is a mandatory redeployment of the VM.



See, I have third-party software running on this Azure VM and its software licensing module (SLM) might need to be reset/reinitialized if the VM gets redeployed. That re-initialization can be a lengthy process because I've got to get on the phone with tech support, request the help, get rerouted who knows how many times, and wait for the reissued license, apply the new license, and test that everything is back to normal. It's something I'm trying to avoid because it might make my team lose a day's worth of work while I get the software manufacturer to reissue/reconfigure my SLM. The SLM relies on the CPUID and MAC ID of its host computer. Since a redeployment implies that the virtual machine may get deployed on a different physical piece of hardware, I would most likely need the SLM reset. I don't want that.



So my questions are,



  • If I shut down the VM for maintenance (such as upgrading an external managed disk from Standard SSD to Premium SSD, for instance), will that force a redeploy?


  • Is a shut down effectively the same as hitting Stop for that VM on the Azure portal?


  • I hear there's a Stop and a separate Stop/Redeploy option, but if so, I don't immediately see that. Is that Redeploy an option I'll see after I hit Stop?







azure deployment






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 5 at 4:05









ShieldOfSalvationShieldOfSalvation

2091 silver badge9 bronze badges




2091 silver badge9 bronze badges















  • I managed to experiment with a separate dummy VM and clicked Stop. The Azure portal immediately warned me that I risked losing the machine's Public IP Address, but gave me the option to reserve it. I told it to go ahead with the Stop regardless because I didn't care about this particular dummy IP. But then I saw that the status of the VM went to "Deallocating". I never got a prompt about whether I wanted to redeploy it. Ooh! Not good news for me! Doesn't a deallocation automatically imply that the next time I restart the VM, it will necessarily be redeployed on potentially different hardware?

    – ShieldOfSalvation
    Aug 5 at 4:23


















  • I managed to experiment with a separate dummy VM and clicked Stop. The Azure portal immediately warned me that I risked losing the machine's Public IP Address, but gave me the option to reserve it. I told it to go ahead with the Stop regardless because I didn't care about this particular dummy IP. But then I saw that the status of the VM went to "Deallocating". I never got a prompt about whether I wanted to redeploy it. Ooh! Not good news for me! Doesn't a deallocation automatically imply that the next time I restart the VM, it will necessarily be redeployed on potentially different hardware?

    – ShieldOfSalvation
    Aug 5 at 4:23

















I managed to experiment with a separate dummy VM and clicked Stop. The Azure portal immediately warned me that I risked losing the machine's Public IP Address, but gave me the option to reserve it. I told it to go ahead with the Stop regardless because I didn't care about this particular dummy IP. But then I saw that the status of the VM went to "Deallocating". I never got a prompt about whether I wanted to redeploy it. Ooh! Not good news for me! Doesn't a deallocation automatically imply that the next time I restart the VM, it will necessarily be redeployed on potentially different hardware?

– ShieldOfSalvation
Aug 5 at 4:23






I managed to experiment with a separate dummy VM and clicked Stop. The Azure portal immediately warned me that I risked losing the machine's Public IP Address, but gave me the option to reserve it. I told it to go ahead with the Stop regardless because I didn't care about this particular dummy IP. But then I saw that the status of the VM went to "Deallocating". I never got a prompt about whether I wanted to redeploy it. Ooh! Not good news for me! Doesn't a deallocation automatically imply that the next time I restart the VM, it will necessarily be redeployed on potentially different hardware?

– ShieldOfSalvation
Aug 5 at 4:23











1 Answer
1






active

oldest

votes


















6














Eureka! I managed to upgrade my managed data disk without having to redeploy the VM! According to the Azure web portal, "Disks can be resized or account type changed only when they are unattached or the owner VM is deallocated." It seemed that if I could unattach/detach the managed disk in question, I could be home free without requiring a stop and deallocation of the VM! In fact, this was so.



I learned that, "You can hot remove a data disk using PowerShell, but make sure nothing is actively using the disk before detaching it from the VM." (Source: see my hyperlink #3 at bottom of this post.) Therefore, I went ahead and stopped my third-party services that depended on that disk, left the VM running, and from my own local PC I performed all the steps I record here.



I will detail further below the custom PowerShell commands I executed (as recorded from my Windows PowerShell ISE user interface, with results embedded, in what I call Phases 1, 2, and 4). I also needed to use the Azure web portal (in what I call Phase 3).



All this WORKED! Note again that I executed my solution in four phases. In brief, they are:



PHASE 1: This was done using PowerShell. Initially, up to the Connect-AzAccount command, what you'll see are preparatory steps that installed the necessary Azure PowerShell modules and set my PC up to allow script execution. I had to click Yes or Yes To All a few times to complete module installations



PHASE 2: Still using PowerShell. Here's where I had to enter my Azure portal credentials when I ran Connect-AzAccount. Basically, I then detach the disk while the VM is still running. That happens at the Remove-AzVMDataDisk command and the Update-AzVM that immediately follows it.



PHASE 3: At that point, I went back to my Azure web portal and I changed my managed data disk from Standard to Premium SSD.



PHASE 4: Finally, I came back to my PowerShell screen and proceeded to perform the steps that led up to the Add-AzVMDataDisk command to reattach my disk to the VM--and the subsequent Update-AzVM that sets that in motion. That brought the upgraded managed disk drive back to life on my VM!



What's even better, all the data was kept intact, the drive letter I had assigned it before was retained, and even the network share name I had given it was still accessible to other VMs via my virtual network!



(Note that in Phase 4, I also performed an additional step to hopefully get optimal Premium SSD performance with a read/write cache: that's the command, 'Set-AzVMDataDisk -VM $VM -Lun "0" -Caching ReadWrite'.)



Now, please observe all the detailed steps I took in PowerShell and what I did in the Azure web portal:



PHASE 1



PS C:WINDOWSsystem32> Install-Module -Name Az -AllowClobber

PS C:WINDOWSsystem32> Get-ExecutionPolicy -List

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined



PS C:WINDOWSsystem32> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

PS C:WINDOWSsystem32> Get-ExecutionPolicy -List

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine Undefined


PHASE 2



PS C:WINDOWSsystem32> Connect-AzAccount

Account SubscriptionName TenantId
------- ---------------- --------
admin@MYCOMPANY.onmicrosoft.com Microsoft Azure (MYCOMPANY): #0000000 ffffff...



PS C:WINDOWSsystem32> $VirtualMachine = Get-AzVM -ResourceGroupName "MYFILESERVERRESOURCES" -Name "MyFileServer"


PS C:WINDOWSsystem32> Remove-AzVMDataDisk -VM $VirtualMachine -Name "MyStorageDrive"



ResourceGroupName : MYFILESERVERRESOURCES
Id : /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resour
ceGroups/MYFILESERVERRESOURCES/providers/Microsoft.Compute/virtualMachines/MY
FileServer
VmId : eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee
Name : MyFileServer
Type : Microsoft.Compute/virtualMachines
Location : eastus
Tags :
DiagnosticsProfile : BootDiagnostics
Extensions : AzureDiskEncryption, AzurePerformanceDiagnostics,
MicrosoftMonitoringAgent
HardwareProfile : VmSize
NetworkProfile : NetworkInterfaces
OSProfile : ComputerName, AdminUsername, WindowsConfiguration,
Secrets, AllowExtensionOperations
ProvisioningState : Succeeded
StorageProfile : ImageReference, OsDisk, DataDisks




PS C:WINDOWSsystem32> Update-AzVM -ResourceGroupName "MYFILESERVERRESOURCES" -VM $VirtualMachine

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK


PHASE 3



Here is where I went back to the Azure portal and changed the drive from Standard SSD to Premium SSD and saved that change! To do so, I,



  1. Signed in to the Azure portal.

  2. Selected the MyFileServer from the list of Virtual Machines in the portal.

  3. I noticed my VM status showed it was still, "Running."

  4. In the pane for the VM, I selected Disks from the menu.

  5. I selected the disk that I wanted to convert, MyStorageDrive.

  6. I selected Configuration from the menu.

  7. I changed the Account type from Standard HDD to Premium SSD (this was impossible before as it was disabled until I detached the disk).

  8. I clicked Save, and closed the disk pane.

The disk conversion was literally instantaneous.



PHASE 4



PS C:WINDOWSsystem32> $rgName = "MYFILESERVERRESOURCES"
$vmName = "MyFileServer"
$location = "East US"
$dataDiskName = "MyStorageDrive"
$disk = Get-AzDisk -ResourceGroupName $rgName -DiskName $dataDiskName


PS C:WINDOWSsystem32> $vm = Get-AzVM -Name $vmName -ResourceGroupName $rgName


PS C:WINDOWSsystem32> $vm = Add-AzVMDataDisk -CreateOption Attach -Lun 0 -VM $vm -ManagedDiskId $disk.Id


PS C:WINDOWSsystem32> Update-AzVM -VM $vm -ResourceGroupName $rgName

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK



PS C:WINDOWSsystem32> $VM.StorageProfile.OsDisk.Caching
ReadWrite

PS C:WINDOWSsystem32> $vm.StorageProfile.DataDisks


Name :
DiskSizeGB :
Lun : 0
Caching : None
CreateOption : Attach
SourceImage :
VirtualHardDisk :




PS C:WINDOWSsystem32> Set-AzVMDataDisk -VM $VM -Lun "0" -Caching ReadWrite


ResourceGroupName : MYFILESERVERRESOURCES
Id : /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MYFILESERVERRESOURCES/providers
/Microsoft.Compute/virtualMachines/MyFileServer
VmId : eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee
Name : MyFileServer
Type : Microsoft.Compute/virtualMachines
Location : eastus
Tags :
DiagnosticsProfile : BootDiagnostics
Extensions : AzureDiskEncryption, AzurePerformanceDiagnostics, MicrosoftMonitoringAgent
HardwareProfile : VmSize
NetworkProfile : NetworkInterfaces
OSProfile : ComputerName, AdminUsername, WindowsConfiguration, Secrets, AllowExtensionOperations
ProvisioningState : Succeeded
StorageProfile : ImageReference, OsDisk, DataDisks




PS C:WINDOWSsystem32> Update-AzVM -VM $vm -ResourceGroupName $rgName

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK



PS C:WINDOWSsystem32>


These are the websites that helped me arrive at this solution:



1 https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6



2 https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-2.5.0



3 https://docs.microsoft.com/en-us/azure/virtual-machines/windows/detach-disk



4 https://docs.microsoft.com/bs-latn-ba/Azure/virtual-machines/windows/convert-disk-storage



5 https://docs.microsoft.com/en-us/azure/virtual-machines/windows/attach-disk-ps



6 https://docs.microsoft.com/en-us/learn/modules/caching-and-performance-azure-storage-and-disks/6-exercise-manage-cache-settings-with-powershell






share|improve this answer






















  • 1





    Great finding and thank you for documenting your results. There's a lot more to do than AWS, where its literally a right-click and update values, with no reboot required.

    – Criggie
    Aug 6 at 0:15













Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f977952%2fcan-i-upgrade-a-managed-disk-used-by-an-azure-vm-without-having-to-redeploy-the%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









6














Eureka! I managed to upgrade my managed data disk without having to redeploy the VM! According to the Azure web portal, "Disks can be resized or account type changed only when they are unattached or the owner VM is deallocated." It seemed that if I could unattach/detach the managed disk in question, I could be home free without requiring a stop and deallocation of the VM! In fact, this was so.



I learned that, "You can hot remove a data disk using PowerShell, but make sure nothing is actively using the disk before detaching it from the VM." (Source: see my hyperlink #3 at bottom of this post.) Therefore, I went ahead and stopped my third-party services that depended on that disk, left the VM running, and from my own local PC I performed all the steps I record here.



I will detail further below the custom PowerShell commands I executed (as recorded from my Windows PowerShell ISE user interface, with results embedded, in what I call Phases 1, 2, and 4). I also needed to use the Azure web portal (in what I call Phase 3).



All this WORKED! Note again that I executed my solution in four phases. In brief, they are:



PHASE 1: This was done using PowerShell. Initially, up to the Connect-AzAccount command, what you'll see are preparatory steps that installed the necessary Azure PowerShell modules and set my PC up to allow script execution. I had to click Yes or Yes To All a few times to complete module installations



PHASE 2: Still using PowerShell. Here's where I had to enter my Azure portal credentials when I ran Connect-AzAccount. Basically, I then detach the disk while the VM is still running. That happens at the Remove-AzVMDataDisk command and the Update-AzVM that immediately follows it.



PHASE 3: At that point, I went back to my Azure web portal and I changed my managed data disk from Standard to Premium SSD.



PHASE 4: Finally, I came back to my PowerShell screen and proceeded to perform the steps that led up to the Add-AzVMDataDisk command to reattach my disk to the VM--and the subsequent Update-AzVM that sets that in motion. That brought the upgraded managed disk drive back to life on my VM!



What's even better, all the data was kept intact, the drive letter I had assigned it before was retained, and even the network share name I had given it was still accessible to other VMs via my virtual network!



(Note that in Phase 4, I also performed an additional step to hopefully get optimal Premium SSD performance with a read/write cache: that's the command, 'Set-AzVMDataDisk -VM $VM -Lun "0" -Caching ReadWrite'.)



Now, please observe all the detailed steps I took in PowerShell and what I did in the Azure web portal:



PHASE 1



PS C:WINDOWSsystem32> Install-Module -Name Az -AllowClobber

PS C:WINDOWSsystem32> Get-ExecutionPolicy -List

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined



PS C:WINDOWSsystem32> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

PS C:WINDOWSsystem32> Get-ExecutionPolicy -List

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine Undefined


PHASE 2



PS C:WINDOWSsystem32> Connect-AzAccount

Account SubscriptionName TenantId
------- ---------------- --------
admin@MYCOMPANY.onmicrosoft.com Microsoft Azure (MYCOMPANY): #0000000 ffffff...



PS C:WINDOWSsystem32> $VirtualMachine = Get-AzVM -ResourceGroupName "MYFILESERVERRESOURCES" -Name "MyFileServer"


PS C:WINDOWSsystem32> Remove-AzVMDataDisk -VM $VirtualMachine -Name "MyStorageDrive"



ResourceGroupName : MYFILESERVERRESOURCES
Id : /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resour
ceGroups/MYFILESERVERRESOURCES/providers/Microsoft.Compute/virtualMachines/MY
FileServer
VmId : eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee
Name : MyFileServer
Type : Microsoft.Compute/virtualMachines
Location : eastus
Tags :
DiagnosticsProfile : BootDiagnostics
Extensions : AzureDiskEncryption, AzurePerformanceDiagnostics,
MicrosoftMonitoringAgent
HardwareProfile : VmSize
NetworkProfile : NetworkInterfaces
OSProfile : ComputerName, AdminUsername, WindowsConfiguration,
Secrets, AllowExtensionOperations
ProvisioningState : Succeeded
StorageProfile : ImageReference, OsDisk, DataDisks




PS C:WINDOWSsystem32> Update-AzVM -ResourceGroupName "MYFILESERVERRESOURCES" -VM $VirtualMachine

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK


PHASE 3



Here is where I went back to the Azure portal and changed the drive from Standard SSD to Premium SSD and saved that change! To do so, I,



  1. Signed in to the Azure portal.

  2. Selected the MyFileServer from the list of Virtual Machines in the portal.

  3. I noticed my VM status showed it was still, "Running."

  4. In the pane for the VM, I selected Disks from the menu.

  5. I selected the disk that I wanted to convert, MyStorageDrive.

  6. I selected Configuration from the menu.

  7. I changed the Account type from Standard HDD to Premium SSD (this was impossible before as it was disabled until I detached the disk).

  8. I clicked Save, and closed the disk pane.

The disk conversion was literally instantaneous.



PHASE 4



PS C:WINDOWSsystem32> $rgName = "MYFILESERVERRESOURCES"
$vmName = "MyFileServer"
$location = "East US"
$dataDiskName = "MyStorageDrive"
$disk = Get-AzDisk -ResourceGroupName $rgName -DiskName $dataDiskName


PS C:WINDOWSsystem32> $vm = Get-AzVM -Name $vmName -ResourceGroupName $rgName


PS C:WINDOWSsystem32> $vm = Add-AzVMDataDisk -CreateOption Attach -Lun 0 -VM $vm -ManagedDiskId $disk.Id


PS C:WINDOWSsystem32> Update-AzVM -VM $vm -ResourceGroupName $rgName

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK



PS C:WINDOWSsystem32> $VM.StorageProfile.OsDisk.Caching
ReadWrite

PS C:WINDOWSsystem32> $vm.StorageProfile.DataDisks


Name :
DiskSizeGB :
Lun : 0
Caching : None
CreateOption : Attach
SourceImage :
VirtualHardDisk :




PS C:WINDOWSsystem32> Set-AzVMDataDisk -VM $VM -Lun "0" -Caching ReadWrite


ResourceGroupName : MYFILESERVERRESOURCES
Id : /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MYFILESERVERRESOURCES/providers
/Microsoft.Compute/virtualMachines/MyFileServer
VmId : eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee
Name : MyFileServer
Type : Microsoft.Compute/virtualMachines
Location : eastus
Tags :
DiagnosticsProfile : BootDiagnostics
Extensions : AzureDiskEncryption, AzurePerformanceDiagnostics, MicrosoftMonitoringAgent
HardwareProfile : VmSize
NetworkProfile : NetworkInterfaces
OSProfile : ComputerName, AdminUsername, WindowsConfiguration, Secrets, AllowExtensionOperations
ProvisioningState : Succeeded
StorageProfile : ImageReference, OsDisk, DataDisks




PS C:WINDOWSsystem32> Update-AzVM -VM $vm -ResourceGroupName $rgName

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK



PS C:WINDOWSsystem32>


These are the websites that helped me arrive at this solution:



1 https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6



2 https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-2.5.0



3 https://docs.microsoft.com/en-us/azure/virtual-machines/windows/detach-disk



4 https://docs.microsoft.com/bs-latn-ba/Azure/virtual-machines/windows/convert-disk-storage



5 https://docs.microsoft.com/en-us/azure/virtual-machines/windows/attach-disk-ps



6 https://docs.microsoft.com/en-us/learn/modules/caching-and-performance-azure-storage-and-disks/6-exercise-manage-cache-settings-with-powershell






share|improve this answer






















  • 1





    Great finding and thank you for documenting your results. There's a lot more to do than AWS, where its literally a right-click and update values, with no reboot required.

    – Criggie
    Aug 6 at 0:15















6














Eureka! I managed to upgrade my managed data disk without having to redeploy the VM! According to the Azure web portal, "Disks can be resized or account type changed only when they are unattached or the owner VM is deallocated." It seemed that if I could unattach/detach the managed disk in question, I could be home free without requiring a stop and deallocation of the VM! In fact, this was so.



I learned that, "You can hot remove a data disk using PowerShell, but make sure nothing is actively using the disk before detaching it from the VM." (Source: see my hyperlink #3 at bottom of this post.) Therefore, I went ahead and stopped my third-party services that depended on that disk, left the VM running, and from my own local PC I performed all the steps I record here.



I will detail further below the custom PowerShell commands I executed (as recorded from my Windows PowerShell ISE user interface, with results embedded, in what I call Phases 1, 2, and 4). I also needed to use the Azure web portal (in what I call Phase 3).



All this WORKED! Note again that I executed my solution in four phases. In brief, they are:



PHASE 1: This was done using PowerShell. Initially, up to the Connect-AzAccount command, what you'll see are preparatory steps that installed the necessary Azure PowerShell modules and set my PC up to allow script execution. I had to click Yes or Yes To All a few times to complete module installations



PHASE 2: Still using PowerShell. Here's where I had to enter my Azure portal credentials when I ran Connect-AzAccount. Basically, I then detach the disk while the VM is still running. That happens at the Remove-AzVMDataDisk command and the Update-AzVM that immediately follows it.



PHASE 3: At that point, I went back to my Azure web portal and I changed my managed data disk from Standard to Premium SSD.



PHASE 4: Finally, I came back to my PowerShell screen and proceeded to perform the steps that led up to the Add-AzVMDataDisk command to reattach my disk to the VM--and the subsequent Update-AzVM that sets that in motion. That brought the upgraded managed disk drive back to life on my VM!



What's even better, all the data was kept intact, the drive letter I had assigned it before was retained, and even the network share name I had given it was still accessible to other VMs via my virtual network!



(Note that in Phase 4, I also performed an additional step to hopefully get optimal Premium SSD performance with a read/write cache: that's the command, 'Set-AzVMDataDisk -VM $VM -Lun "0" -Caching ReadWrite'.)



Now, please observe all the detailed steps I took in PowerShell and what I did in the Azure web portal:



PHASE 1



PS C:WINDOWSsystem32> Install-Module -Name Az -AllowClobber

PS C:WINDOWSsystem32> Get-ExecutionPolicy -List

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined



PS C:WINDOWSsystem32> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

PS C:WINDOWSsystem32> Get-ExecutionPolicy -List

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine Undefined


PHASE 2



PS C:WINDOWSsystem32> Connect-AzAccount

Account SubscriptionName TenantId
------- ---------------- --------
admin@MYCOMPANY.onmicrosoft.com Microsoft Azure (MYCOMPANY): #0000000 ffffff...



PS C:WINDOWSsystem32> $VirtualMachine = Get-AzVM -ResourceGroupName "MYFILESERVERRESOURCES" -Name "MyFileServer"


PS C:WINDOWSsystem32> Remove-AzVMDataDisk -VM $VirtualMachine -Name "MyStorageDrive"



ResourceGroupName : MYFILESERVERRESOURCES
Id : /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resour
ceGroups/MYFILESERVERRESOURCES/providers/Microsoft.Compute/virtualMachines/MY
FileServer
VmId : eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee
Name : MyFileServer
Type : Microsoft.Compute/virtualMachines
Location : eastus
Tags :
DiagnosticsProfile : BootDiagnostics
Extensions : AzureDiskEncryption, AzurePerformanceDiagnostics,
MicrosoftMonitoringAgent
HardwareProfile : VmSize
NetworkProfile : NetworkInterfaces
OSProfile : ComputerName, AdminUsername, WindowsConfiguration,
Secrets, AllowExtensionOperations
ProvisioningState : Succeeded
StorageProfile : ImageReference, OsDisk, DataDisks




PS C:WINDOWSsystem32> Update-AzVM -ResourceGroupName "MYFILESERVERRESOURCES" -VM $VirtualMachine

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK


PHASE 3



Here is where I went back to the Azure portal and changed the drive from Standard SSD to Premium SSD and saved that change! To do so, I,



  1. Signed in to the Azure portal.

  2. Selected the MyFileServer from the list of Virtual Machines in the portal.

  3. I noticed my VM status showed it was still, "Running."

  4. In the pane for the VM, I selected Disks from the menu.

  5. I selected the disk that I wanted to convert, MyStorageDrive.

  6. I selected Configuration from the menu.

  7. I changed the Account type from Standard HDD to Premium SSD (this was impossible before as it was disabled until I detached the disk).

  8. I clicked Save, and closed the disk pane.

The disk conversion was literally instantaneous.



PHASE 4



PS C:WINDOWSsystem32> $rgName = "MYFILESERVERRESOURCES"
$vmName = "MyFileServer"
$location = "East US"
$dataDiskName = "MyStorageDrive"
$disk = Get-AzDisk -ResourceGroupName $rgName -DiskName $dataDiskName


PS C:WINDOWSsystem32> $vm = Get-AzVM -Name $vmName -ResourceGroupName $rgName


PS C:WINDOWSsystem32> $vm = Add-AzVMDataDisk -CreateOption Attach -Lun 0 -VM $vm -ManagedDiskId $disk.Id


PS C:WINDOWSsystem32> Update-AzVM -VM $vm -ResourceGroupName $rgName

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK



PS C:WINDOWSsystem32> $VM.StorageProfile.OsDisk.Caching
ReadWrite

PS C:WINDOWSsystem32> $vm.StorageProfile.DataDisks


Name :
DiskSizeGB :
Lun : 0
Caching : None
CreateOption : Attach
SourceImage :
VirtualHardDisk :




PS C:WINDOWSsystem32> Set-AzVMDataDisk -VM $VM -Lun "0" -Caching ReadWrite


ResourceGroupName : MYFILESERVERRESOURCES
Id : /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MYFILESERVERRESOURCES/providers
/Microsoft.Compute/virtualMachines/MyFileServer
VmId : eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee
Name : MyFileServer
Type : Microsoft.Compute/virtualMachines
Location : eastus
Tags :
DiagnosticsProfile : BootDiagnostics
Extensions : AzureDiskEncryption, AzurePerformanceDiagnostics, MicrosoftMonitoringAgent
HardwareProfile : VmSize
NetworkProfile : NetworkInterfaces
OSProfile : ComputerName, AdminUsername, WindowsConfiguration, Secrets, AllowExtensionOperations
ProvisioningState : Succeeded
StorageProfile : ImageReference, OsDisk, DataDisks




PS C:WINDOWSsystem32> Update-AzVM -VM $vm -ResourceGroupName $rgName

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK



PS C:WINDOWSsystem32>


These are the websites that helped me arrive at this solution:



1 https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6



2 https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-2.5.0



3 https://docs.microsoft.com/en-us/azure/virtual-machines/windows/detach-disk



4 https://docs.microsoft.com/bs-latn-ba/Azure/virtual-machines/windows/convert-disk-storage



5 https://docs.microsoft.com/en-us/azure/virtual-machines/windows/attach-disk-ps



6 https://docs.microsoft.com/en-us/learn/modules/caching-and-performance-azure-storage-and-disks/6-exercise-manage-cache-settings-with-powershell






share|improve this answer






















  • 1





    Great finding and thank you for documenting your results. There's a lot more to do than AWS, where its literally a right-click and update values, with no reboot required.

    – Criggie
    Aug 6 at 0:15













6












6








6







Eureka! I managed to upgrade my managed data disk without having to redeploy the VM! According to the Azure web portal, "Disks can be resized or account type changed only when they are unattached or the owner VM is deallocated." It seemed that if I could unattach/detach the managed disk in question, I could be home free without requiring a stop and deallocation of the VM! In fact, this was so.



I learned that, "You can hot remove a data disk using PowerShell, but make sure nothing is actively using the disk before detaching it from the VM." (Source: see my hyperlink #3 at bottom of this post.) Therefore, I went ahead and stopped my third-party services that depended on that disk, left the VM running, and from my own local PC I performed all the steps I record here.



I will detail further below the custom PowerShell commands I executed (as recorded from my Windows PowerShell ISE user interface, with results embedded, in what I call Phases 1, 2, and 4). I also needed to use the Azure web portal (in what I call Phase 3).



All this WORKED! Note again that I executed my solution in four phases. In brief, they are:



PHASE 1: This was done using PowerShell. Initially, up to the Connect-AzAccount command, what you'll see are preparatory steps that installed the necessary Azure PowerShell modules and set my PC up to allow script execution. I had to click Yes or Yes To All a few times to complete module installations



PHASE 2: Still using PowerShell. Here's where I had to enter my Azure portal credentials when I ran Connect-AzAccount. Basically, I then detach the disk while the VM is still running. That happens at the Remove-AzVMDataDisk command and the Update-AzVM that immediately follows it.



PHASE 3: At that point, I went back to my Azure web portal and I changed my managed data disk from Standard to Premium SSD.



PHASE 4: Finally, I came back to my PowerShell screen and proceeded to perform the steps that led up to the Add-AzVMDataDisk command to reattach my disk to the VM--and the subsequent Update-AzVM that sets that in motion. That brought the upgraded managed disk drive back to life on my VM!



What's even better, all the data was kept intact, the drive letter I had assigned it before was retained, and even the network share name I had given it was still accessible to other VMs via my virtual network!



(Note that in Phase 4, I also performed an additional step to hopefully get optimal Premium SSD performance with a read/write cache: that's the command, 'Set-AzVMDataDisk -VM $VM -Lun "0" -Caching ReadWrite'.)



Now, please observe all the detailed steps I took in PowerShell and what I did in the Azure web portal:



PHASE 1



PS C:WINDOWSsystem32> Install-Module -Name Az -AllowClobber

PS C:WINDOWSsystem32> Get-ExecutionPolicy -List

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined



PS C:WINDOWSsystem32> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

PS C:WINDOWSsystem32> Get-ExecutionPolicy -List

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine Undefined


PHASE 2



PS C:WINDOWSsystem32> Connect-AzAccount

Account SubscriptionName TenantId
------- ---------------- --------
admin@MYCOMPANY.onmicrosoft.com Microsoft Azure (MYCOMPANY): #0000000 ffffff...



PS C:WINDOWSsystem32> $VirtualMachine = Get-AzVM -ResourceGroupName "MYFILESERVERRESOURCES" -Name "MyFileServer"


PS C:WINDOWSsystem32> Remove-AzVMDataDisk -VM $VirtualMachine -Name "MyStorageDrive"



ResourceGroupName : MYFILESERVERRESOURCES
Id : /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resour
ceGroups/MYFILESERVERRESOURCES/providers/Microsoft.Compute/virtualMachines/MY
FileServer
VmId : eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee
Name : MyFileServer
Type : Microsoft.Compute/virtualMachines
Location : eastus
Tags :
DiagnosticsProfile : BootDiagnostics
Extensions : AzureDiskEncryption, AzurePerformanceDiagnostics,
MicrosoftMonitoringAgent
HardwareProfile : VmSize
NetworkProfile : NetworkInterfaces
OSProfile : ComputerName, AdminUsername, WindowsConfiguration,
Secrets, AllowExtensionOperations
ProvisioningState : Succeeded
StorageProfile : ImageReference, OsDisk, DataDisks




PS C:WINDOWSsystem32> Update-AzVM -ResourceGroupName "MYFILESERVERRESOURCES" -VM $VirtualMachine

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK


PHASE 3



Here is where I went back to the Azure portal and changed the drive from Standard SSD to Premium SSD and saved that change! To do so, I,



  1. Signed in to the Azure portal.

  2. Selected the MyFileServer from the list of Virtual Machines in the portal.

  3. I noticed my VM status showed it was still, "Running."

  4. In the pane for the VM, I selected Disks from the menu.

  5. I selected the disk that I wanted to convert, MyStorageDrive.

  6. I selected Configuration from the menu.

  7. I changed the Account type from Standard HDD to Premium SSD (this was impossible before as it was disabled until I detached the disk).

  8. I clicked Save, and closed the disk pane.

The disk conversion was literally instantaneous.



PHASE 4



PS C:WINDOWSsystem32> $rgName = "MYFILESERVERRESOURCES"
$vmName = "MyFileServer"
$location = "East US"
$dataDiskName = "MyStorageDrive"
$disk = Get-AzDisk -ResourceGroupName $rgName -DiskName $dataDiskName


PS C:WINDOWSsystem32> $vm = Get-AzVM -Name $vmName -ResourceGroupName $rgName


PS C:WINDOWSsystem32> $vm = Add-AzVMDataDisk -CreateOption Attach -Lun 0 -VM $vm -ManagedDiskId $disk.Id


PS C:WINDOWSsystem32> Update-AzVM -VM $vm -ResourceGroupName $rgName

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK



PS C:WINDOWSsystem32> $VM.StorageProfile.OsDisk.Caching
ReadWrite

PS C:WINDOWSsystem32> $vm.StorageProfile.DataDisks


Name :
DiskSizeGB :
Lun : 0
Caching : None
CreateOption : Attach
SourceImage :
VirtualHardDisk :




PS C:WINDOWSsystem32> Set-AzVMDataDisk -VM $VM -Lun "0" -Caching ReadWrite


ResourceGroupName : MYFILESERVERRESOURCES
Id : /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MYFILESERVERRESOURCES/providers
/Microsoft.Compute/virtualMachines/MyFileServer
VmId : eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee
Name : MyFileServer
Type : Microsoft.Compute/virtualMachines
Location : eastus
Tags :
DiagnosticsProfile : BootDiagnostics
Extensions : AzureDiskEncryption, AzurePerformanceDiagnostics, MicrosoftMonitoringAgent
HardwareProfile : VmSize
NetworkProfile : NetworkInterfaces
OSProfile : ComputerName, AdminUsername, WindowsConfiguration, Secrets, AllowExtensionOperations
ProvisioningState : Succeeded
StorageProfile : ImageReference, OsDisk, DataDisks




PS C:WINDOWSsystem32> Update-AzVM -VM $vm -ResourceGroupName $rgName

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK



PS C:WINDOWSsystem32>


These are the websites that helped me arrive at this solution:



1 https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6



2 https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-2.5.0



3 https://docs.microsoft.com/en-us/azure/virtual-machines/windows/detach-disk



4 https://docs.microsoft.com/bs-latn-ba/Azure/virtual-machines/windows/convert-disk-storage



5 https://docs.microsoft.com/en-us/azure/virtual-machines/windows/attach-disk-ps



6 https://docs.microsoft.com/en-us/learn/modules/caching-and-performance-azure-storage-and-disks/6-exercise-manage-cache-settings-with-powershell






share|improve this answer















Eureka! I managed to upgrade my managed data disk without having to redeploy the VM! According to the Azure web portal, "Disks can be resized or account type changed only when they are unattached or the owner VM is deallocated." It seemed that if I could unattach/detach the managed disk in question, I could be home free without requiring a stop and deallocation of the VM! In fact, this was so.



I learned that, "You can hot remove a data disk using PowerShell, but make sure nothing is actively using the disk before detaching it from the VM." (Source: see my hyperlink #3 at bottom of this post.) Therefore, I went ahead and stopped my third-party services that depended on that disk, left the VM running, and from my own local PC I performed all the steps I record here.



I will detail further below the custom PowerShell commands I executed (as recorded from my Windows PowerShell ISE user interface, with results embedded, in what I call Phases 1, 2, and 4). I also needed to use the Azure web portal (in what I call Phase 3).



All this WORKED! Note again that I executed my solution in four phases. In brief, they are:



PHASE 1: This was done using PowerShell. Initially, up to the Connect-AzAccount command, what you'll see are preparatory steps that installed the necessary Azure PowerShell modules and set my PC up to allow script execution. I had to click Yes or Yes To All a few times to complete module installations



PHASE 2: Still using PowerShell. Here's where I had to enter my Azure portal credentials when I ran Connect-AzAccount. Basically, I then detach the disk while the VM is still running. That happens at the Remove-AzVMDataDisk command and the Update-AzVM that immediately follows it.



PHASE 3: At that point, I went back to my Azure web portal and I changed my managed data disk from Standard to Premium SSD.



PHASE 4: Finally, I came back to my PowerShell screen and proceeded to perform the steps that led up to the Add-AzVMDataDisk command to reattach my disk to the VM--and the subsequent Update-AzVM that sets that in motion. That brought the upgraded managed disk drive back to life on my VM!



What's even better, all the data was kept intact, the drive letter I had assigned it before was retained, and even the network share name I had given it was still accessible to other VMs via my virtual network!



(Note that in Phase 4, I also performed an additional step to hopefully get optimal Premium SSD performance with a read/write cache: that's the command, 'Set-AzVMDataDisk -VM $VM -Lun "0" -Caching ReadWrite'.)



Now, please observe all the detailed steps I took in PowerShell and what I did in the Azure web portal:



PHASE 1



PS C:WINDOWSsystem32> Install-Module -Name Az -AllowClobber

PS C:WINDOWSsystem32> Get-ExecutionPolicy -List

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined



PS C:WINDOWSsystem32> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

PS C:WINDOWSsystem32> Get-ExecutionPolicy -List

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine Undefined


PHASE 2



PS C:WINDOWSsystem32> Connect-AzAccount

Account SubscriptionName TenantId
------- ---------------- --------
admin@MYCOMPANY.onmicrosoft.com Microsoft Azure (MYCOMPANY): #0000000 ffffff...



PS C:WINDOWSsystem32> $VirtualMachine = Get-AzVM -ResourceGroupName "MYFILESERVERRESOURCES" -Name "MyFileServer"


PS C:WINDOWSsystem32> Remove-AzVMDataDisk -VM $VirtualMachine -Name "MyStorageDrive"



ResourceGroupName : MYFILESERVERRESOURCES
Id : /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resour
ceGroups/MYFILESERVERRESOURCES/providers/Microsoft.Compute/virtualMachines/MY
FileServer
VmId : eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee
Name : MyFileServer
Type : Microsoft.Compute/virtualMachines
Location : eastus
Tags :
DiagnosticsProfile : BootDiagnostics
Extensions : AzureDiskEncryption, AzurePerformanceDiagnostics,
MicrosoftMonitoringAgent
HardwareProfile : VmSize
NetworkProfile : NetworkInterfaces
OSProfile : ComputerName, AdminUsername, WindowsConfiguration,
Secrets, AllowExtensionOperations
ProvisioningState : Succeeded
StorageProfile : ImageReference, OsDisk, DataDisks




PS C:WINDOWSsystem32> Update-AzVM -ResourceGroupName "MYFILESERVERRESOURCES" -VM $VirtualMachine

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK


PHASE 3



Here is where I went back to the Azure portal and changed the drive from Standard SSD to Premium SSD and saved that change! To do so, I,



  1. Signed in to the Azure portal.

  2. Selected the MyFileServer from the list of Virtual Machines in the portal.

  3. I noticed my VM status showed it was still, "Running."

  4. In the pane for the VM, I selected Disks from the menu.

  5. I selected the disk that I wanted to convert, MyStorageDrive.

  6. I selected Configuration from the menu.

  7. I changed the Account type from Standard HDD to Premium SSD (this was impossible before as it was disabled until I detached the disk).

  8. I clicked Save, and closed the disk pane.

The disk conversion was literally instantaneous.



PHASE 4



PS C:WINDOWSsystem32> $rgName = "MYFILESERVERRESOURCES"
$vmName = "MyFileServer"
$location = "East US"
$dataDiskName = "MyStorageDrive"
$disk = Get-AzDisk -ResourceGroupName $rgName -DiskName $dataDiskName


PS C:WINDOWSsystem32> $vm = Get-AzVM -Name $vmName -ResourceGroupName $rgName


PS C:WINDOWSsystem32> $vm = Add-AzVMDataDisk -CreateOption Attach -Lun 0 -VM $vm -ManagedDiskId $disk.Id


PS C:WINDOWSsystem32> Update-AzVM -VM $vm -ResourceGroupName $rgName

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK



PS C:WINDOWSsystem32> $VM.StorageProfile.OsDisk.Caching
ReadWrite

PS C:WINDOWSsystem32> $vm.StorageProfile.DataDisks


Name :
DiskSizeGB :
Lun : 0
Caching : None
CreateOption : Attach
SourceImage :
VirtualHardDisk :




PS C:WINDOWSsystem32> Set-AzVMDataDisk -VM $VM -Lun "0" -Caching ReadWrite


ResourceGroupName : MYFILESERVERRESOURCES
Id : /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MYFILESERVERRESOURCES/providers
/Microsoft.Compute/virtualMachines/MyFileServer
VmId : eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee
Name : MyFileServer
Type : Microsoft.Compute/virtualMachines
Location : eastus
Tags :
DiagnosticsProfile : BootDiagnostics
Extensions : AzureDiskEncryption, AzurePerformanceDiagnostics, MicrosoftMonitoringAgent
HardwareProfile : VmSize
NetworkProfile : NetworkInterfaces
OSProfile : ComputerName, AdminUsername, WindowsConfiguration, Secrets, AllowExtensionOperations
ProvisioningState : Succeeded
StorageProfile : ImageReference, OsDisk, DataDisks




PS C:WINDOWSsystem32> Update-AzVM -VM $vm -ResourceGroupName $rgName

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK



PS C:WINDOWSsystem32>


These are the websites that helped me arrive at this solution:



1 https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6



2 https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-2.5.0



3 https://docs.microsoft.com/en-us/azure/virtual-machines/windows/detach-disk



4 https://docs.microsoft.com/bs-latn-ba/Azure/virtual-machines/windows/convert-disk-storage



5 https://docs.microsoft.com/en-us/azure/virtual-machines/windows/attach-disk-ps



6 https://docs.microsoft.com/en-us/learn/modules/caching-and-performance-azure-storage-and-disks/6-exercise-manage-cache-settings-with-powershell







share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 5 at 20:07

























answered Aug 5 at 6:16









ShieldOfSalvationShieldOfSalvation

2091 silver badge9 bronze badges




2091 silver badge9 bronze badges










  • 1





    Great finding and thank you for documenting your results. There's a lot more to do than AWS, where its literally a right-click and update values, with no reboot required.

    – Criggie
    Aug 6 at 0:15












  • 1





    Great finding and thank you for documenting your results. There's a lot more to do than AWS, where its literally a right-click and update values, with no reboot required.

    – Criggie
    Aug 6 at 0:15







1




1





Great finding and thank you for documenting your results. There's a lot more to do than AWS, where its literally a right-click and update values, with no reboot required.

– Criggie
Aug 6 at 0:15





Great finding and thank you for documenting your results. There's a lot more to do than AWS, where its literally a right-click and update values, with no reboot required.

– Criggie
Aug 6 at 0:15

















draft saved

draft discarded
















































Thanks for contributing an answer to Server Fault!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f977952%2fcan-i-upgrade-a-managed-disk-used-by-an-azure-vm-without-having-to-redeploy-the%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?