Azure / azure-rest-api-specs

The source for REST API specifications for Microsoft Azure.
MIT License
2.63k stars 5.08k forks source link

SubscriptionClient: cannot create alias subscription with management group #24025

Open mvalenzisi opened 1 year ago

mvalenzisi commented 1 year ago

Describe the bug I try to create a subscription with the following piece of code:

subscription = subscription_client.alias.begin_create(
    alias_name=name,
    body=subscription_models.PutAliasRequest(
        properties=subscription_models.PutAliasRequestProperties(
            display_name=name,
            workload=subscription_models.Workload.PRODUCTION,
            billing_scope=billing_scope,
            additional_properties=subscription_models.PutAliasRequestAdditionalProperties(
                management_group_id=management_group,
                subscription_tenant_id=tenant_id
            )
        )
    )
)

The management group ID is: general (from the Azure portal). If I pass management_group_id="general" I get the error:

Subscription creation failed since provided management group id is not in the expected format (/providers/Microsoft.Management/managementGroups/{mgmtGroupId})

If I pass management_group_id="/providers/Microsoft.Management/managementGroups/general" I get the error:

Subscription creation failed since provided management group id is not valid

To Reproduce See above

Expected behavior The subscription should be created when I pass management_group="/providers/Microsoft.Management/managementGroups/general"

kashifkhan commented 1 year ago

Thank you for the feedback @mvalenzisi . We will investigate and get back to you asap.

msyyc commented 1 year ago

Hi, service team. I am not the expert in subscription and I don't find example declare what management_group_id looks like. Could you help give an sample to show how to set management_group_id?

mvalenzisi commented 1 year ago

I found this similar issue and it is exactly my case. The service principal that I'm using was not authorized to add the subscription to the management group. The error returned by the API is misleading.

ghost commented 1 year ago

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

Issue Details
- **Package Name**: azure-mgmt-subscription - **Package Version**: 3.1.1 - **Operating System**: Linux - **Python Version**: 3.9.16 **Describe the bug** I try to create a subscription with the following piece of code: ``` subscription = subscription_client.alias.begin_create( alias_name=name, body=subscription_models.PutAliasRequest( properties=subscription_models.PutAliasRequestProperties( display_name=name, workload=subscription_models.Workload.PRODUCTION, billing_scope=billing_scope, additional_properties=subscription_models.PutAliasRequestAdditionalProperties( management_group_id=management_group, subscription_tenant_id=tenant_id ) ) ) ) ``` The management group ID is: `general` (from the Azure portal). If I pass `management_group_id="general"` I get the error: ``` Subscription creation failed since provided management group id is not in the expected format (/providers/Microsoft.Management/managementGroups/{mgmtGroupId}) ``` If I pass `management_group_id="/providers/Microsoft.Management/managementGroups/general"` I get the error: ``` Subscription creation failed since provided management group id is not valid ``` **To Reproduce** See above **Expected behavior** The subscription should be created when I pass `management_group="/providers/Microsoft.Management/managementGroups/general"`
Author: mvalenzisi
Assignees: -
Labels: `question`, `Service Attention`, `Subscription`, `customer-reported`, `Mgmt`, `needs-team-attention`
Milestone: -
navba-MSFT commented 1 year ago

Adding service team to look into this.