Crying Cloud

Patrick Mahon

Break an Infinite Lease on an Azure Storage Account Container

StorageContainerLeaseLock-2.png

On rare occasions you may find yourself with an empty storage account container that has an infinite lease on it. This can make it near impossible to remove the container without opening a support case with Microsoft. While there are several tools and script samples available to break the lease on a blob there are few that address a lease on a container. The following should help identify if your container has an “infinite” lease and how to remove the lease.

Symptoms:

The following are symptoms of an infinite lease on a empty container:

  1. When viewing the properties of the container through the portal (https://portal.azure.com) you will see the lease period set to “infinite”.
  2. When deleting the Azure storage container though the new portal (https://portal.azure.com) you get the following error:
    • “Failed to delete storage container 'MyLeasedContainer'. Error: There is currently a lease on the container and no lease ID was specified in the request.”"
  3. When deleting the Azure storage container though the old portal(https://manage.windowsazure.com) you get the following error:
    • “There is currently a lease on the container and no lease ID was specified in the request. RequestId:5f0e6c7c-0001-00ec-7df9-0fc697000000 Time:2016-09-16T09:04:45.6778058Z”

Resolution:

The following script sample can help break this lease. Replace the property values of $StorageAccountName, $StorageAccountKey, and $ContainerName with the correct values of the container with the infinite lease.

[powershell]

$StorageAccountName = "MyStorageAccount"

$StorageAccountKey = "flmuQKvp7L6G8ga0IXLMnPJogSacsFPofKBv1g2sJhfcecVyrWtu+AMweHNwgSk6dAkOWTGx1viyQp/0aMRkBw=="

$ContainerName = "MyLeasedContainer"

$Creds = New-Object Microsoft.WindowsAzure.Storage.Auth.StorageCredentials("$StorageAccountName","$StorageAccountKey")

$CloudStorageAccount = New-Object Microsoft.WindowsAzure.Storage.CloudStorageAccount($creds, $true)

$CloudBlobClient = $CloudStorageAccount.CreateCloudBlobClient()

$BlobContainer = $CloudBlobClient.GetContainerReference($ContainerName)

$BlobContainer.BreakLease($(New-TimeSpan), $null, $null, $null)

[/powershell]

 

Disk to LUN Mapping for a Windows VM using Microsoft Storage Spaces in Azure

disks.jpg

When multiple data disks are attached to a Windows VM using Microsoft Storage Spaces in Azure it can be difficult to identify the LUN a disk belongs to. This is especially troublesome when there is a need to delete, clone, or migrate a specific disk(s) from on VM to another VM in Azure. A scenario where this may come in handy is if you need to migrate only 1 or 2 disks associated with Microsoft Storage Spaces while leaving other disks in place on the VM.

When a disk is not associated with a storage pool the disk’s LUN can easily be seen in Location property of the general tab on the disk’s properties under the “Disk Management” utility.

When a disk is associated with a storage pool the disk will not show up in the “Disk Management” utility and the LUN is not easily viewable because of this.

The following can help identify the Disk to LUN Mapping on your Windows VM in Azure when Microsoft Storage Spaces are used.

We will collect some information on some of the disks displayed in Device Manager. Use this information to identify the LUNs of the disks you would like to delete, clone, or migrate. You will need to do these steps for each of the “Microsoft Storage Space Device” objects in the “Disks drives” object in the Device Manager utility.

  • Physical Device Object Name – Can be used as the unique identifier for the “Microsoft Storage Space Device”.
  • Volume and Drive Letter(s) – Will show what volumes are associated with the storage space device.
  • Volume Capacity – This is optional but helpful to see.
  • Power relations – Identifies uniquely each “Microsoft Virtual Disk” used by the “Microsoft Storage Space Device”.
  • LUN ID(s) – This derived by manually converting the last 6 characters of each of the “Power Relations” values (see above) from HEX to Decimal.

1. Open Device Manager

a. Remote Desktop into your Azure VM that has the disks you would like to delete, clone, or migrate.

b. Right-Click Start Menu –> Select “Device Manager”

2. Get properties of the “Disk drives” object.

Note: This will need to be done for each of the “Microsoft Storage Space Device”

a. Right Click on the “Microsoft Storage Space Device” object and select properties.

01-DeviceManager

 

3. Get the “Microsoft Storage Space Device” object’s “Physical Device Object name” property.

a. Select the “Details” tab of the “Microsoft Storage Space Device” properties window.

b. Select the “Physical Device Object name” property in the “Property” field dropdown menu.

c. Write down the “Physical Device Object Name” value for this “Microsoft Storage Space Device”.

Sample Value: “\Device\Space1”

03-DeviceManagerDevicePropertiesDetails-Physical Device Object name

4. Get the Volumes associated with the “Microsoft Storage Space Device”.

a. Select the “Volumes” tab of the “Microsoft Storage Space Device” properties window.

b. Click the “Populate” button to retrieve all volume information for this “Microsoft Storage Space Device”.

02a-DeviceManagerDevicePropertiesVolumes-Unpopulated

c. For each volume in the “Microsoft Storage Space Device” make note of the “Volume” and “Capacity” fields.

Sample Value “Volume”: “volume-on-pool-a (M:)”

Sample Value “Capacity”: “2016MB”

02b-DeviceManagerDevicePropertiesVolumes-Populated

 

5. Get the “Power relations” properties for the “Microsoft Storage Space Device”.

a. Select the “Details” tab of the “Microsoft Storage Space Device” properties window.

b. Select the “Power relations” property in the “Property” field dropdown menu.

c. Write down the “Power relations” value(s) for this “Microsoft Storage Space Device”.

Sample “Power relations” Value(s):

SCSI\Disk&Ven_Msft&Prod_Virtual_Disk\000001

SCSI\Disk&Ven_Msft&Prod_Virtual_Disk\000000

 

04-DeviceManagerDevicePropertiesDetails-Power relations

6. Identify the LUN information in the “Power relations” Value string(s) and convert from HEX to Decimal.

Note: The LUN information is stored in hexadecimal format as the last 6 characters on the “Power relations” Value string(s). At this time this will need to be manually identified and converted to a decimal format for LUN identification. See this sample data below:

Sample “Power relations” value: “SCSI\Disk&Ven_Msft&Prod_Virtual_Disk\00001c

Sample Hexadecimal value (last six characters from above):00001c

Sample LUN ID (converted from HEX): “28”

a. Get the last 6 characters of the “Power relation” string(s).

b. Convert the last 6 characters from hexadecimal to decimal using Calc.exe (in Programmer mode). This is the LUN ID.

c. Note down the LUN ID with the other collected information.

 

Below are some example tables that were created using the method above. These can be used to aggregate the data when multiple disks are involved.

 

Volumes Table

Microsoft Storage Space Device (Physical Device Object Name)

Drive Letter

Volume Name

Capacity

\Device\Space1

M:

volume-on-pool-a (M:)

2016 MB

\Device\Space2

N:

volume-on-pool-b (N:)

2016 MB

 

Power Relations Table (LUNs)

Microsoft Storage Space Device (Physical Device Object Name)

Power relations

HEX (Manual - Last 6 of Power Relations)

LUN (Manual - Convert Hex to Decimal)

\Device\Space1                                         

SCSI\Disk&Ven_Msft&Prod_Virtual_Disk\000001

000001

1

\Device\Space1

SCSI\Disk&Ven_Msft&Prod_Virtual_Disk\000000

000000

0

\Device\Space2

SCSI\Disk&Ven_Msft&Prod_Virtual_Disk\000003

000003

3

\Device\Space2

SCSI\Disk&Ven_Msft&Prod_Virtual_Disk\000002

000002

2