OfficeDev / teams-toolkit

Developer tools for building Teams apps
Other
454 stars 183 forks source link

Unable to Provision in the Cloud when partner account is linked to multiple tenants. #12044

Open cdrenshaw opened 1 month ago

cdrenshaw commented 1 month ago

I encountered the exact same issue described here when attempting to provision my Teams app in the cloud using the Teams Toolkit. My Office 365 partner account is linked to multiple tenants and the wizard fails to list my Azure subscriptions/resources. In one of the SO comments, the OP states he used FiddlerScript to rewrite the response from /tenants so that it only returned a single tenant ID. I can confirm that intercepting/rewriting the response resolves the issue, but this is kind of a hassle.

I'm using VS 17.10.4 and Teams Toolkit 17.10.63.65054.

MuyangAmigo commented 1 month ago

Hey @cdrenshaw - Teams Toolkit today doesn't support selecting a tenant via UI. As a workaround, you can configure default tenants via Azure Portal: https://learn.microsoft.com/en-us/azure/devtest/offer/how-to-change-directory-tenants-visual-studio-azure

This is considered as a feature request for Teams Toolkit and we will keep you updated.

cdrenshaw commented 1 month ago

Thanks for the response. Unfortunately, this solution didn't work for me. The subscription is already in my default tenant and my account defaults to the correct tenant when I open the Azure portal. Additionally, I have a filter set on my Visual Studio login so that only the default tenant is selected.

MuyangAmigo commented 1 month ago

You mean your desired subscription is linked in the default tenant, and VS selects that tenant, but Teams Toolkit failed to show it?

cdrenshaw commented 1 month ago

My account was created in "Tenant A". Tenant A is where the subscription is. Tenant A is my default tenant in the Azure portal. Visual Studio is filtered to only Tenant A and also shows it is the default.

When I right-click my TeamsApp project, and select Teams Toolkit > Provision in the Cloud, the provision window opens and says loading subscriptions. image

Then it fails and says I need to re-enter my credentials. image

If I click "Re-enter your credentials", it goes back to loading subscriptions, then again says to re-enter my credentials.

When I inspect the traffic from my computer, it shows a GET call to https://management.azure.com/tenants?api-version=2016-06-01 which returns several results. Rewriting the response with Fiddler to return only a single tenant resolves the issue.

xiaolang124 commented 1 month ago

Sorry for the inconvenience. This may be caused by your account lacking some permissions in certain tenants. We have fixed this issue in version 17.11. You can try using the VS preview version or wait for this version to become stable.

jeanplevesque commented 1 month ago

I have the same problem and the preview version (Version 17.11.0 Preview 7.0) seems to work correctly. Thanks!

refex commented 4 days ago

I have the same issue, this is driving me mad. Absolutely unusable and provisioning is now down to being lucky to randomly target the right tenant

xiaolang124 commented 3 days ago

@refex Hi, can you tell me which VS version are you using? Does VS 17.11 solve your problem? Do you mean the provisioned tenant doesn't match the tenant you selected? If you've provisioned once, your Teams app will always use the selected tenant for provisioning. You can try deleting this information from your environment file to resolve the issue. (Like ZURE_SUBSCRIPTION_ID and AZURE_RESOURCE_GROUP_NAME in './env/'.env.dev')