Deallocation problem for VM

Tomas Ežeras Smulkys 0 Reputation points
2025-05-02T10:38:35.5966667+00:00

The VM gets deallocated. I need it to run 24/7. I am the sole developer of our project and I've minimal knowledge of cloud services, so I might've set this up incorrectly and need to set this up so it runs 24/7 and we get billed from our credit monthly, not per use. We need to retain the IP and disk information as I've set everything up.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,755 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Durga Reshma Malthi 30 Reputation points Microsoft External Staff
    2025-05-02T14:29:05.4566667+00:00

    Spot VMs in Azure cannot be converted directly to regular VMs because they are billed differently and may be deallocated when capacity is low. You cannot convert a Spot VM directly to a regular VM, but you can reuse its disk.

    1. Go to Azure Portal -> Select your Spot VM -> Stop the VM.
    2. Create a snapshot of your VM’s OS disk to ensure you have a backup.
    3. Make sure not to delete the associated disk and IP address.
    4. Now create a new Standard VM (Choose Standard pricing model and uncheck Azure Spot Instance if necessary) with the same OS and configurations.
    5. Attach the existing disk and static IP to the new VM.
    6. Once the new VM is working, then delete the old spot VM [not the disk, IP or NIC unless unused]

    Since you're using an Azure grant for non-profits, check if you qualify for reserved instances, which provide predictable monthly billing

    1 person found this answer helpful.
    0 comments No comments

  2. Durga Reshma Malthi 30 Reputation points Microsoft External Staff
    2025-05-02T12:23:02.8233333+00:00

    Hi Tomas Ežeras Smulkys

    Could you please tell me which cloud provider you are using for your VM? (e.g., Microsoft Azure, AWS, Google Cloud Platform, or another). This will help me to provide detailed instructions.

    Meanwhile, please check the following and configure accordingly:

    1. Check if automatic shutdown is enabled under VM settings. Azure Portal -> Navigate to your VM -> In the left-hand menu, under Operations -> Auto-shutdown. If auto-shutdown is enabled, turn it off or disable any scheduled shutdown. If your VM stops randomly, check Azure Automation Accounts for any automated policies that may be shutting it down.
    2. In Azure, ensure the VM isn't part of a scale set that shuts down when unused. Avoid Spot VMs, as they can be deallocated when Azure requires capacity. Also ensure your VM is using Managed Disks instead of Ephemeral OS Disks.
    3. In Azure assign a Static Public IP instead of a dynamic one. Go to your VM’s Networking settings and change the public IP to static. In AWS use an Elastic IP to retain the same IP address even when restarting instances.
    4. If you're using Microsoft Azure, ensure you're on a Pay-As-You-Go or Reserved Instances plan rather than a spot or ephemeral VM that deallocates based on availability. If you're using AWS, consider switching from EC2 Spot instances to On-Demand or Reserved instances for more predictable billing.
    5. If your VM runs 24/7, the billing accumulates hourly and is shown monthly. Using your Azure credits, the cost will be deducted monthly until credits expire. There is no separate monthly flat fee unless you opt for reserved VM instances (1 or 3 year). If you want a flat monthly price, you can consider reserved VM instances, but that requires commitment depending on your cloud provider. Additional references:

    https://learn.microsoft.com/en-us/azure/virtual-machines/auto-shutdown-vm?tabs=portal

    https://learn.microsoft.com/en-us/answers/questions/540521/azure-virtual-machine-stopped-deallocated

    Hope this helps!

    Please Let me know if you have any queries.

    0 comments No comments

  3. Nasif Ishtiaque Islam 0 Reputation points
    2025-05-02T13:16:51.3633333+00:00

    It sounds like your virtual machine (VM) is currently on a usage-based (pay-per-use) plan and may be auto-deallocating when idle or due to a budget constraint or incorrect setting.

    Here's a guide to keep your VM running 24/7, retain its public IP and disk, and ensure you're billed monthly using your Azure credit (assuming you're using Azure; let me know if it's AWS/GCP instead):


    1. Prevent Auto-Deallocation

    If the VM is getting auto-deallocated:

    • Go to Azure Portal > Virtual Machines > Select your VM.

    Check the Auto-shutdown setting (under "Operations").

    Disable auto-shutdown if it's enabled.

    Ensure you're not using Azure Dev/Test Labs, which can deallocate VMs based on schedules.


    1. Ensure Static Public IP

    Dynamic IPs are released when VMs deallocate. To retain your public IP:

    Go to Virtual Network Interface > IP Configurations.

    Select the IP configuration and change assignment from "Dynamic" to "Static".

    This keeps your IP even if the VM is stopped (as long as the NIC isn't deleted).


    1. Ensure Disk Retention

    Disks are persistent by default in Azure, but double-check:

    Under the VM settings, go to Disks.

    Ensure the OS Disk and Data Disks are not temporary and are managed disks (they usually are by default).

    If you're using a temporary disk (/dev/sdb1 on Linux or D: on Windows), that data will be lost after a reboot — avoid storing anything critical there.


    1. Billing and Always-On Mode

    To ensure you're billed monthly and the VM stays on:

    Choose a Reserved Instance (RI) or Azure Savings Plan, which reduces costs if you're running 24/7.

    Go to Cost Management + Billing > Reservations.

    Reserve a VM of the same type/region to get lower prices (still billed monthly).

    Ensure you’re not using a spot VM, which is cheaper but can be deallocated anytime.

    Check this under your VM’s "Overview" or "Configuration".


    1. Link to Monthly Credit

    If you have Azure credit (e.g., through Visual Studio subscription or MSDN), ensure it’s:

    • Properly linked to your subscription.
    • You're using the correct subscription for deploying your VM (check this in "Subscriptions").

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.