prompty icon indicating copy to clipboard operation
prompty copied to clipboard

Tenant switching

Open 07JP27 opened this issue 1 year ago • 9 comments

Hi team,

I have joined multiple tenants. When I try to run a prompty file in VS Code, the default tenant is selected automatically. However, the Azure OpenAI model I am trying to use is deployed in another tenant, so I cannot authenticate with AAD.

Is there any way to switch tenants when running a prompt or a workaround for this issue?

07JP27 avatar Jul 01 '24 09:07 07JP27

Great question - the extension relies on the underlying system settings when it comes to identity. My go to approach is to use the az login approach to sign in to the right places. Let me know what you think.

sethjuarez avatar Jul 03 '24 17:07 sethjuarez

I also confirmed that vscode.authentication.getSession() is used in the prompty extension's code.

Creating and using the CLI is a good idea to realize this issue, and it allows execution in other IDEs or shells. If you still keep the VS Code extension, you can emit the CLI command behind the GUI action.

The CLI command I hope:

prompty login --tenant xxxxxxxxxxxxxx (-> Browser poping up)
prompty create --file xxxxx.prompty
prompty run --file xxxxx.prompty
prompty generate --lang-chain --file xxxxx.prompty
prompty generate --semantic-kernel --file xxxxx.prompty
prompty generate --prompt-flow --file xxxxx.prompty

07JP27 avatar Jul 04 '24 13:07 07JP27

Interesting idea!! I will label this as a feature request.

sethjuarez avatar Jul 07 '24 06:07 sethjuarez

vscode 1.93 added support for choosing accounts when getting a session

pelikhan avatar Sep 06 '24 05:09 pelikhan

I am stuck at this point now. I did my auth login for prompty, but it is not using my correct tenant. I've tried authenticating with az login but Prompty still tries to run against the wrong tenant.

DavidBurela avatar Sep 16 '24 05:09 DavidBurela

Ugh - I am sorry! In general the AOAI prompty executor uses the currently logged in tenant if the key is not specified. Usually something like:

az login

sould fix the issue. You can also switch the tenant using:

az login --tenant <tenant_id>

Hopefully this works.

sethjuarez avatar Sep 16 '24 18:09 sethjuarez

Hi there, I also have a similar issue. I'm connected with my one of the MS tenant which is not the default one. I have used the cmd az login --tenat <tenant_id> as you suggested @sethjuarez to authenticate in the correct tenant but still prompty is trying to generate the AAD auth token with the MS principal tenant (not where the resources are deployed).

Here is the error I get : Image

prompty extension version : v0.1.2024092301 (pre-release)

I can only make it work if I use the API_key.

any suggestion ? I think it would be great to switch tenant to use in prompty as suggested by @07JP27.

lisaWolffhugelMS avatar Dec 20 '24 08:12 lisaWolffhugelMS

Can we have a way to specify the tenant ID in the settings? You could see how the GitHub Copilot for Azure does it - they added a /changeTenant command to make it easy to switch tenants.

pamelafox avatar Jan 14 '25 17:01 pamelafox

Running into this issue when trying to use prompty in Azure DevOps:

Using the Azure CLI task to login with my service connection and it seems to pick the wrong tenant.


    - task: AzureCLI@2
      displayName: Run (AzureCLI@2)
      inputs:
        azureSubscription: my-subscription
        scriptType: bash
        scriptLocation: inlineScript
        inlineScript: |
          az account set --subscription "xxxxxxxxxxx"

          # Verify the context
          az account show --query '{subscription:name,tenant:tenantId}'

          python run.py

{'error': {'code': 'Tenant provided in token does not match resource token', 'message': 'Token tenant xxxxxxxxxxxx does not match resource tenant.'}}

+1 for adding a way to specify the tenant with prompty.

kristapratico avatar May 21 '25 20:05 kristapratico