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

subscription class should return the tags associated with the subscription

Open nancybelser opened this issue 6 years ago • 17 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

nancybelser avatar Mar 10 '20 19:03 nancybelser

https://docs.microsoft.com/en-us/python/api/azure-mgmt-subscription/azure.mgmt.subscription.models.subscription?view=azure-python This class does not include tags, although tags are included in the rest api: image

nancybelser avatar Mar 10 '20 19:03 nancybelser

@nancybelser thanks for reporting this, @nickzhums could you take a look at this?

kaerm avatar Mar 10 '20 20:03 kaerm

Any status updates on this?

nancybelser avatar Mar 27 '20 14:03 nancybelser

@RodgeFu please have someone take a look at this, thanks!

nickzhums avatar Mar 27 '20 14:03 nickzhums

Hi @nancybelser , would you help to provide the link address for the rest api doc you showed? Thanks.

changlong-liu avatar Mar 28 '20 05:03 changlong-liu

It is on this page: https://docs.microsoft.com/en-us/rest/api/resources/subscriptions/get?view=azurermps-6.9.0

nancybelser avatar Mar 30 '20 14:03 nancybelser

We are setting tag values on our subscriptions. I need to retrieve those values in a python script I am currently writing.

nancybelser avatar Mar 30 '20 15:03 nancybelser

Hi @nancybelser , the rest api you referred is actually belong to azure-mgmt-resource, not the azure-mgmt-subscription in your python doc link. And meanwhile, the SDK release is sometime behind the rest api release, the 'tags' feature has not been added into current azure-mgmt-resource SDK. It's expected that it can be included in the next release of azure-mgmt-resource.

changlong-liu avatar Apr 01 '20 06:04 changlong-liu

I see this issue got added to the backlog. Does that mean it will not be worked on anytime soon?

nancybelser avatar May 05 '20 20:05 nancybelser

Hi @nancybelser No, it doesn't mean that, this is just the default milestone while we are investigating the issue we want to prioritize. I let @zikalino and @changlong-liu give you a more concrete answer on the status of the issue. Thanks!

lmazuel avatar May 06 '20 18:05 lmazuel

Hi @nancybelser , the subscription tag retrieving feature has been included in azure-mgmt-resource 9.0.0 released at early April. https://pypi.org/project/azure-mgmt-resource/9.0.0/.

changlong-liu avatar May 07 '20 02:05 changlong-liu

Hi @changlong-liu,

I upgraded to latest azure-mgmt-resource, but I noticed that the class I am using to list all subscriptions is in azure-mgmt-subscription.

In this file, https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models.py:

I think this needs to change to include tags: _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'state': {'key': 'state', 'type': 'SubscriptionState'}, 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, 'authorization_source': {'key': 'authorizationSource', 'type': 'str'},

This is an excerpt of my script: def get_subscriptions(credentials): subscription_client = SubscriptionClient(credentials) subscriptions = subscription_client.subscriptions.list() for subscription in subscriptions: print(subscription)

It does not return tags.

Thanks.

nancybelser avatar May 08 '20 00:05 nancybelser

yes, @nancybelser, azure-mgmt-subscriptions don't have tag yet. If you just want to retrieve subscription tags, would you have a try on azure-mgmt-resource? https://github.com/Azure/azure-sdk-for-python/blob/cd25de58e00d624511b5154e9fe8683826020bc0/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models_py3.py#L293

changlong-liu avatar May 08 '20 07:05 changlong-liu

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @anuragdalmia, @shilpigautam, @ramaganesan-rg.

ghost avatar May 08 '20 07:05 ghost

Just tried it and it worked. Thanks!

From: changlong-liu [email protected] Reply-To: Azure/azure-sdk-for-python [email protected] Date: Friday, May 8, 2020 at 3:33 AM To: Azure/azure-sdk-for-python [email protected] Cc: Nancy Belser [email protected], Mention [email protected] Subject: Re: [Azure/azure-sdk-for-python] subscription class should return the tags associated with the subscription (#10240)

yes, @nancybelserhttps://github.com/nancybelser, azure-mgmt-subscriptions don't have tag yet. If you just want to retrieve subscription tags, would you have a try on azure-mgmt-resource? https://github.com/Azure/azure-sdk-for-python/blob/cd25de58e00d624511b5154e9fe8683826020bc0/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models_py3.py#L293https://github.com/Azure/azure-sdk-for-python/blob/cd25de58e00d624511b5154e9fe8683826020bc0/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models_py3.py#L293

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-sdk-for-python/issues/10240#issuecomment-625681666, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJ3OJ57NXBN44DJJJ4OYN43RQOYSXANCNFSM4LFGYV6A.

nancybelser avatar May 08 '20 14:05 nancybelser

Thanks for feedback @nancybelser , I close this issue for now.

changlong-liu avatar May 12 '20 02:05 changlong-liu

hi @nancybelser how did you list the tags for the subscriptions? mine shows up as "none"

ie:

{'additional_properties': {}, 'id': '/subscriptions/4e37827xxx00f3d5d', 'subscription_id': '4e378272-xxxf3d5d', 'display_name': 'display name', 'tenant_id': '5d3exxx', 'state': 'Enabled', 'subscription_policies': <azure.mgmt.resource.subscriptions.v2021_01_01.models._models_py3.SubscriptionPolicies object at 0x106f4df90>, 'authorization_source': 'RoleBased', 'managed_by_tenants': [], 'tags': None}

tanjoht avatar Mar 23 '23 18:03 tanjoht