{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/6610","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/6610/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/6610/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/6610/events","html_url":"https://github.com/hashicorp/terraform/issues/6610","id":154186351,"number":6610,"title":"destroy azure rm virtual machine doesn't destroy it's vhd blob (meaning apply will fail the next time)","user":{"login":"MattFenner","id":1695492,"avatar_url":"https://avatars.githubusercontent.com/u/1695492?v=3","gravatar_id":"","url":"https://api.github.com/users/MattFenner","html_url":"https://github.com/MattFenner","followers_url":"https://api.github.com/users/MattFenner/followers","following_url":"https://api.github.com/users/MattFenner/following{/other_user}","gists_url":"https://api.github.com/users/MattFenner/gists{/gist_id}","starred_url":"https://api.github.com/users/MattFenner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MattFenner/subscriptions","organizations_url":"https://api.github.com/users/MattFenner/orgs","repos_url":"https://api.github.com/users/MattFenner/repos","events_url":"https://api.github.com/users/MattFenner/events{/privacy}","received_events_url":"https://api.github.com/users/MattFenner/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hashicorp/terraform/labels/bug","name":"bug","color":"f7c6c7"},{"url":"https://api.github.com/repos/hashicorp/terraform/labels/provider/azurerm","name":"provider/azurerm","color":"bfdadc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-05-11T08:22:44Z","updated_at":"2016-05-12T23:35:39Z","closed_at":null,"body":"I believe this is a bug but i am new to azure and terraform so maybe i am just doing things wrong.\r\n\r\ni have a terraform configuration which creates a virtual machine and all the networking and storage to go along with it. and i want to be able to destroy the vm and recreate it regularly.\r\n\r\nhowever when i call:\r\n```\r\nterraform destroy -target=\"azurerm_virtual_machine.WS\"\r\nterraform apply\r\n```\r\n\r\nit fails on the apply because the destroy never cleaned up the associated vhd created for the storage of the OS for the image.\r\n\r\nNOTE: I only want to recreate the virtual machine and not everything so that the process is much quicker.\r\n\r\n\r\nhere is my terraform config for reference:\r\n```\r\nprovider \"azurerm\" {\r\n\t# see https://www.terraform.io/docs/providers/azurerm/index.html\r\n\t# Credentials must be provided via the ARM_SUBSCRIPTION_ID, ARM_CLIENT_ID, ARM_CLIENT_SECRET and ARM_TENANT_ID environment variables\r\n}\r\n\r\n# Create a resource group\r\nresource \"azurerm_resource_group\" \"ait\" {\r\n    name     = \"ait-res-group\"\r\n    location = \"Australia Southeast\"\r\n}\r\n\r\n# Create a virtual network\r\nresource \"azurerm_virtual_network\" \"ait\" {\r\n  name                = \"ait-net\"\r\n  address_space       = [\"10.0.0.0/16\"]\r\n  location            = \"Australia Southeast\"\r\n  resource_group_name = \"${azurerm_resource_group.ait.name}\"\r\n}\r\n\r\nresource \"azurerm_subnet\" \"ait\" {\r\n    name = \"subnet\"\r\n    resource_group_name = \"${azurerm_resource_group.ait.name}\"\r\n    virtual_network_name = \"${azurerm_virtual_network.ait.name}\"\r\n    address_prefix = \"10.0.1.0/24\"\r\n}\r\n\r\nresource \"azurerm_public_ip\" \"ait\" {\r\n    name = \"aitpublicip\"\r\n    location = \"Australia Southeast\"\r\n    resource_group_name = \"${azurerm_resource_group.ait.name}\"\r\n    public_ip_address_allocation = \"static\"\r\n\r\n    tags {\r\n        environment = \"Production\"\r\n    }\r\n}\r\n\r\nresource \"azurerm_network_interface\" \"ait\" {\r\n    name = \"ait-net-int\"\r\n    location = \"Australia Southeast\"\r\n    resource_group_name = \"${azurerm_resource_group.ait.name}\"\r\n\r\n    network_security_group_id = \"${azurerm_network_security_group.ait.id}\"\r\n\r\n    ip_configuration {\r\n        name = \"ait-config\"\r\n        subnet_id = \"${azurerm_subnet.ait.id}\"\r\n        private_ip_address_allocation = \"dynamic\"\r\n        public_ip_address_id = \"${azurerm_public_ip.ait.id}\"\r\n    }\r\n}\r\n\r\nresource \"azurerm_network_security_group\" \"ait\" {\r\n    name = \"ait-netsecgrp\"\r\n    location = \"Australia Southeast\"\r\n    resource_group_name = \"${azurerm_resource_group.ait.name}\"\r\n\r\n    security_rule {\r\n        name = \"allowtcp\"\r\n        priority = 1000\r\n        direction = \"Inbound\"\r\n        access = \"Allow\"\r\n        protocol = \"Tcp\"\r\n        source_port_range = \"*\"\r\n        destination_port_range = \"*\"\r\n        source_address_prefix = \"*\"\r\n        destination_address_prefix = \"*\"\r\n    }\r\n\r\n    tags {\r\n        environment = \"Production\"\r\n    }\r\n}\r\n\r\nresource \"azurerm_storage_account\" \"ait\" {\r\n    name = \"aitstoragetransmax\"\r\n    resource_group_name = \"${azurerm_resource_group.ait.name}\"\r\n    location = \"Australia Southeast\"\r\n    account_type = \"Standard_LRS\"\r\n\r\n    tags {\r\n        environment = \"ait\"\r\n    }\r\n}\r\n\r\nresource \"azurerm_storage_container\" \"ait\" {\r\n    name = \"vhds\"\r\n    resource_group_name = \"${azurerm_resource_group.ait.name}\"\r\n    storage_account_name = \"${azurerm_storage_account.ait.name}\"\r\n    container_access_type = \"private\"\r\n}\r\n\r\n# Create a VM\r\nresource \"azurerm_virtual_machine\" \"WS\" {\r\n    name = \"ait-ws81\"\r\n    location = \"Australia Southeast\"\r\n    resource_group_name = \"${azurerm_resource_group.ait.name}\"\r\n    network_interface_ids = [\"${azurerm_network_interface.ait.id}\"]\r\n    vm_size = \"Standard_D2_V2\" #2 core, 7GB RAM, 4x500IOPS\r\n\r\n    storage_image_reference {\r\n        publisher = \"MicrosoftVisualStudio\"\r\n        offer = \"Windows\"\r\n        sku = \"8.1-Enterprise-N\"\r\n        version = \"latest\"\r\n    }\r\n\r\n    storage_os_disk {\r\n        name = \"aitWS81disk\"\r\n        vhd_uri = \"${azurerm_storage_account.ait.primary_blob_endpoint}${azurerm_storage_container.ait.name}/ait-ws81-disk.vhd\"\r\n        caching = \"ReadWrite\"\r\n        create_option = \"FromImage\"\r\n    }\r\n\r\n    os_profile {\r\n        computer_name = \"ait-ws81\"\r\n        admin_username = \"aituser\"\r\n        admin_password = \"Password!\"\r\n    }\r\n\r\n    os_profile_windows_config {\r\n    \tenable_automatic_upgrades = true\r\n\t}\r\n\r\n    tags {\r\n        environment = \"ait\"\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/218915437","html_url":"https://github.com/hashicorp/terraform/issues/6610#issuecomment-218915437","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/6610","id":218915437,"user":{"login":"MattFenner","id":1695492,"avatar_url":"https://avatars.githubusercontent.com/u/1695492?v=3","gravatar_id":"","url":"https://api.github.com/users/MattFenner","html_url":"https://github.com/MattFenner","followers_url":"https://api.github.com/users/MattFenner/followers","following_url":"https://api.github.com/users/MattFenner/following{/other_user}","gists_url":"https://api.github.com/users/MattFenner/gists{/gist_id}","starred_url":"https://api.github.com/users/MattFenner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MattFenner/subscriptions","organizations_url":"https://api.github.com/users/MattFenner/orgs","repos_url":"https://api.github.com/users/MattFenner/repos","events_url":"https://api.github.com/users/MattFenner/events{/privacy}","received_events_url":"https://api.github.com/users/MattFenner/received_events","type":"User","site_admin":false},"created_at":"2016-05-12T23:35:39Z","updated_at":"2016-05-12T23:35:39Z","body":"@stack72 i think i did mean the blob. IMO it should delete the blob for the disk (which is configured as part of the VM), but it should leave the container which is specified as a separate container"}}