Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paging async iterator protocol is not available (Azure SDK for Python)

What I'm trying to achieve

I'm trying to automate subscription and resource group creation on Azure using the Python SDK.

To do that, I need a Service Principal Account (Client Id; Client Secret; Tenant Id) with Permissions to at least retrieve Enrollment Accounts and create the subscriptions and resource groups.


How I'm trying to achieve it

I tried listing the enrollment accounts without success (yes, I'm importing azure.mgmt.billing, azure.mgmt and azure.common, among others)

  1. First I instantiate the client:

    billing_client = azure.mgmt.billing.BillingManagementClient(credentials, subscription_id)
    
  2. Then I tried printing the results in two different ways:

    # A
    print(list(billing_client.enrollment_accounts.list()))
    
    # B
    for enrollment_account in billing_client.enrollment_accounts.list():
        print(enrollment_account)
    

What problem am I facing?

The problem I'm experiencing is that I get the following error:

Paging async iterator protocol is not available for EnrollmentAccountPaged

This also happens with other list() methods, like when I retrieve resource groups using something like

rm_client = ResourceManagementClient(credentials, subscription_id)
resource_groups = rm_client.resource_groups.list()

Then, I get the error:

Paging async iterator protocol is not available for ResourceGroupPaged


How would I consider my problem solved?

I'd love to know why I'm getting this error, and how to fix it. The example code from Azure doesn't use the methods or objects in a different way.


How's the environment?

Python version: Python 3.7

Packages:

Package Version Latest Version
PyJWT   1.6.4   1.6.4
adal    1.1.0   1.1.0
asn1crypto  0.24.0  0.24.0
azure-common    1.1.16  1.1.16
azure-mgmt  4.0.0   4.0.0
azure-mgmt-advisor  1.0.1   1.0.1
azure-mgmt-applicationinsights  0.1.1   0.1.1
azure-mgmt-authorization    0.50.0  0.50.0
azure-mgmt-batch    5.0.1   5.0.1
azure-mgmt-batchai  2.0.0   2.0.0
azure-mgmt-billing  0.2.0   0.2.0
azure-mgmt-cdn  3.0.0   3.0.0
azure-mgmt-cognitiveservices    3.0.0   3.0.0
azure-mgmt-commerce 1.0.1   1.0.1
azure-mgmt-compute  4.3.0   4.3.0
azure-mgmt-consumption  2.0.0   2.0.0
azure-mgmt-containerinstance    1.2.0   1.2.0
azure-mgmt-containerregistry    2.2.0   2.2.0
azure-mgmt-containerservice 4.2.2   4.2.2
azure-mgmt-cosmosdb 0.4.1   0.5.0
azure-mgmt-datafactory  0.6.0   0.6.0
azure-mgmt-datalake-analytics   0.6.0   0.6.0
azure-mgmt-datalake-nspkg   2.0.0   3.0.0
azure-mgmt-datalake-store   0.5.0   0.5.0
azure-mgmt-datamigration    1.0.0   2.0.0
azure-mgmt-devspaces    0.1.0   0.1.0
azure-mgmt-devtestlabs  2.2.0   2.2.0
azure-mgmt-dns  2.1.0   2.1.0
azure-mgmt-eventgrid    1.0.0   1.0.0
azure-mgmt-eventhub 2.1.0   2.1.0
azure-mgmt-hanaonazure  0.1.1   0.2.1
azure-mgmt-iotcentral   0.1.0   0.2.0
azure-mgmt-iothub   0.5.0   0.6.0
azure-mgmt-iothubprovisioningservices   0.2.0   0.2.0
azure-mgmt-keyvault 1.1.0   1.1.0
azure-mgmt-loganalytics 0.2.0   0.2.0
azure-mgmt-logic    3.0.0   3.0.0
azure-mgmt-machinelearningcompute   0.4.1   0.4.1
azure-mgmt-managementgroups 0.1.0   0.1.0
azure-mgmt-managementpartner    0.1.0   0.1.0
azure-mgmt-maps 0.1.0   0.1.0
azure-mgmt-marketplaceordering  0.1.0   0.1.0
azure-mgmt-media    1.0.0   1.0.0
azure-mgmt-monitor  0.5.2   0.5.2
azure-mgmt-msi  0.2.0   0.2.0
azure-mgmt-network  2.2.1   2.2.1
azure-mgmt-notificationhubs 2.0.0   2.0.0
azure-mgmt-nspkg    3.0.2   3.0.2
azure-mgmt-policyinsights   0.1.0   0.1.0
azure-mgmt-powerbiembedded  2.0.0   2.0.0
azure-mgmt-rdbms    1.3.0   1.3.0
azure-mgmt-recoveryservices 0.3.0   0.3.0
azure-mgmt-recoveryservicesbackup   0.3.0   0.3.0
azure-mgmt-redis    5.0.0   5.0.0
azure-mgmt-relay    0.1.0   0.1.0
azure-mgmt-reservations 0.2.1   0.3.0
azure-mgmt-resource 2.0.0   2.0.0
azure-mgmt-scheduler    2.0.0   2.0.0
azure-mgmt-search   2.0.0   2.0.0
azure-mgmt-servicebus   0.5.2   0.5.2
azure-mgmt-servicefabric    0.2.0   0.2.0
azure-mgmt-signalr  0.1.1   0.1.1
azure-mgmt-sql  0.9.1   0.9.1
azure-mgmt-storage  2.0.0   3.0.0
azure-mgmt-subscription 0.2.0   0.2.0
azure-mgmt-trafficmanager   0.50.0  0.50.0
azure-mgmt-web  0.35.0  0.40.0
azure-nspkg 3.0.2   3.0.2
certifi 2018.8.24   2018.8.24
cffi    1.11.5  1.11.5
chardet 3.0.4   3.0.4
cryptography    2.3.1   2.3.1
idna    2.7 2.7
isodate 0.6.0   0.6.0
msrest  0.6.0   0.6.0
msrestazure 0.5.0   0.5.0
oauthlib    2.1.0   2.1.0
pip 10.0.1  18.1
pycparser   2.19    2.19
python-dateutil 2.7.3   2.7.3
requests    2.19.1  2.19.1
requests-oauthlib   1.0.0   1.0.0
setuptools  39.1.0  40.4.3
like image 295
Kevin Mai Avatar asked Sep 26 '26 09:09

Kevin Mai


1 Answers

This is a log warning to tell you that this package is not ready to support async syntax, and this is true, we released the first part of the runtime in msrest 0.6.0, but we didn't released any packages with async support yet.

For reference that it's just a warning: https://github.com/Azure/msrest-for-python/blob/master/msrest/async_paging.py#L40

It will not impact any code and will not raise any exception. You will get a problem only if you try to use async for of async syntax (because as the warning tells you, it's not ready for).

When we'll start shipping async compatible packages by the end of this year, this warning will disappear automatically as more and more package becomes ready.

If this warning is really a problem for you, you can disable the logger "msrest.async_paging" or pin msrest to 0.5.5 (before async core support).

Feel free to open an issue on our tracker if you feel this is really a massive problem, and depending on how many people I get bad feedback, I might change it to debug for a few months. But once async packages will be released, it will be an important source of feedback and I truly think it would deserve a warning. https://github.com/Azure/azure-sdk-for-python/issues

Thank you for your feedback!

(I own this code at Microsoft).

Edit: Being that you're not the only one with questions about this, I released a 0.6.1 that removes this warning.

like image 77
Laurent Mazuel Avatar answered Sep 27 '26 22:09

Laurent Mazuel