azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Create disk isn't using the managed disk parameters

Open apavlovptc opened this issue 5 years ago • 8 comments

This used to work, but since a few days this code is always creating "Standart HDD" disk type. Here is the code:

diskParams = {
    'location': "westeurope",
    'disk_size_gb': 128,
    'managed_disk': {
        'storage_account_type': 'Premium_LRS'
    },
    'creation_data': {
        'create_option': 'Empty'
    }
}

newDisk = compute_client.disks.create_or_update(
    "test-resource-group",
    "test-disk-name",
    diskParams
)

datadisk = newDisk.result()
print('Created Managed Disk:   ' + datadisk.name)

PS. Similar command still works when creating OS disks, but not for other disks. I tried different values for "storage_account_type" from here: https://docs.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2020_12_01.models.manageddiskparameters?view=azure-python But no change. I always end up with HDD disk.

Any Ideas, why could it be? Was there any change introduced recently?

apavlovptc avatar Mar 29 '21 14:03 apavlovptc

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Drewm3, @vaibhav-agar.

Issue Details

This used to work, but since a few days this code is always creating "Standart HDD" disk type. Here is the code:

diskParams = {
    'location': "westeurope",
    'disk_size_gb': 128,
    'managed_disk': {
        'storage_account_type': 'Premium_LRS'
    },
    'creation_data': {
        'create_option': 'Empty'
    }
}

newDisk = compute_client.disks.create_or_update(
    "test-resource-group",
    "test-disk-name",
    diskParams
)

datadisk = newDisk.result()
print('Created Managed Disk:   ' + datadisk.name)

PS. Similar command still works when creating OS disks, but not for other disks. I tried different values for "storage_account_type" from here: https://docs.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2020_12_01.models.manageddiskparameters?view=azure-python But no change. I always end up with HDD disk.

Any Ideas, why could it be? Was there any change introduced recently?

Author: apavlovptc
Assignees: -
Labels:

Compute - Managed Disks, Mgmt, Service Attention, bug, customer-reported

Milestone: -

ghost avatar Mar 29 '21 21:03 ghost

@Vaibhav-Agar, could you help on this question.

@apavlovptc, could you share which version(s) of the Python SDK you are using, and could you confirm that you changed SDK versions between the two attempts? If we ever change API behavior we do it only on new versions of the RESTful API. A specific SDK is bound to a specific REST API version. So a change should only show up when moving to different SDKs. Of course it is possible that there is a service side bug, though. So, we'll try to reproduce the behavior and see if this is a service side bug.

Drewm3 avatar Mar 31 '21 16:03 Drewm3

Hi, thanks for reply. No we performed no updates on our side between the attempts. How can I check the SDK version? In Azure portal I see only module versions: image

This behavior with wrong disk type could also be reproduced in a new python 3 runbook, where only a single data disk is provisioned.

In the meanwhile we have found a 'fix' by substituting the values:

FROM:
'managed_disk': {'storage_account_type': 'Premium_LRS'},

TO:
'sku': {'name': 'Premium_LRS'},

and this behaves as expected, but its not mentioned in reference documentation. https://docs.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2020_12_01.models.manageddiskparameters?view=azure-python

apavlovptc avatar Apr 01 '21 21:04 apavlovptc

Update. I have received the following reply from Azure support, also suggesting to seek support here. Maybe this can help:

Hi Alex ,

I have done several tests in Azure Automation and got the same results as you then I tried the following code on the cloud shell to get Automation out of picture (and eliminate any issues with package)

-I installed the latest packages python in the cloud shell -tried this code

The outcome is exactly the same so the issue is in the package implementation

Since the development of this is managed on GitHub , please report this on the package page here azure-sdk-for-python/sdk/compute/azure-mgmt-compute at master · Azure/azure-sdk-for-python · GitHub

Regards, Iyad

Code tested in cloud shell

from azure.mgmt.resource import SubscriptionClient
from azure.identity import ClientSecretCredential

import azure.mgmt.resource
import azure.mgmt.storage
import azure.mgmt.compute
import azure.mgmt.network 

# Retrieve the IDs and secret to use with ClientSecretCredential
subscription_id = "xxx"
tenant_id = "xxx"
client_id = "xxx"
client_secret = "xxx

azure_credential = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
subscription_client = SubscriptionClient(azure_credential)
subscription = next(subscription_client.subscriptions.list())

resource_client = azure.mgmt.resource.ResourceManagementClient(azure_credential,subscription_id)
compute_client = azure.mgmt.compute.ComputeManagementClient(azure_credential, subscription_id)
network_client = azure.mgmt.network.NetworkManagementClient(azure_credential,subscription_id)
storage_client = azure.mgmt.storage.StorageManagementClient(azure_credential,subscription_id)

rgName = "RG-TestPythonDisk"
size = 1
env_location = "westeurope"

def createDataDisk(rgName,size):   
    diskName = "disk1"
    diskParams = {
        'location': env_location,
        'disk_size_gb': str(size),
        'managed_disk': {
                    'storage_account_type': 'Premium_LRS'
        },
        'creation_data': {
            'create_option': 'Empty'
        }
    }
    newDisk = compute_client.disks.begin_create_or_update(
        rgName,
        diskName,
        diskParams
    )
    datadisk = newDisk.result()
    print('Created Managed Disk:   ' + datadisk.name)
    return datadisk
    
createDataDisk(rgName,size)

apavlovptc avatar Apr 06 '21 07:04 apavlovptc

Will look into this today. Apologies for the delay.

Vaibhav-Agar avatar Apr 23 '21 17:04 Vaibhav-Agar

Unable to reproduce using REST apis so have reached out to the python SDK team.

Vaibhav-Agar avatar May 11 '21 23:05 Vaibhav-Agar

hi @apavlovptc In the AZURE-DOCs I found that ManagedDiskParameters are only supported in OSDisk class image Meanwhile in Disk class, the supported parameter is sku. image https://docs.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2020_12_01.models.disk?view=azure-python So I think the 'fix' you mentioned above is correct.

FROM:
'managed_disk': {'storage_account_type': 'Premium_LRS'},

TO:
'sku': {'name': 'Premium_LRS'},

RAY-316 avatar Jun 22 '21 03:06 RAY-316

Closing the issue, please reopen if needed

oriwolman avatar Oct 14 '21 20:10 oriwolman