Azure-Samples / azure-search-openai-demo-csharp

A sample app for the Retrieval-Augmented Generation pattern running in Azure, using Azure Cognitive Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.
MIT License
615 stars 403 forks source link

Authorization failed message on prepdocs.ps1 #195

Open mikepugh opened 11 months ago

mikepugh commented 11 months ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Set environment variables to existing resources Run azd auth login execute .\scripts\prepdocs.ps1

Any log messages given by the failure


Status: 403 (Forbidden)

Content: {"error":{"code":"","message":"Authorization failed."}}

Headers: Server: Microsoft-IIS/10.0 Strict-Transport-Security: REDACTED Preference-Applied: REDACTED client-request-id: 9... x-ms-client-request-id: 9... request-id: 9... elapsed-time: 11 Date: Mon, 16 Oct 2023 14:37:56 GMT Content-Length: 55 Content-Type: application/json; charset=utf-8 Content-Language: REDACTED

at Azure.Search.Documents.IndexesRestClient.ListAsync(String select, CancellationToken cancellationToken) at Azure.Search.Documents.Indexes.SearchIndexClient.<>c__DisplayClass58_0.<b__0>d.MoveNext() --- End of stack trace from previous location ---



### Expected/desired behavior
> The prepdocs script to execute successfully

### OS and Version?
> Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)
Windows 10
### Versions
> azd version 1.4.2 (commit 694107efa395b8562abcdf1f246792bbea72ad9c)

### Mention any other details that might be useful
azd auth login does not appear to work to authenticate despite repeated attempts, clearing the ~\.azd\auth folder, etc. azd auth login --debug shows no errors and appears to work fine, however my prepdocs script always fails with the above error when the script attempts to lookup the indexes on my cognitive search service.
> ---------------------------------------------------------------
> Thanks! We'll be in touch soon.
luisquintanilla commented 11 months ago

@mikepugh if you look in your .azure/\<env-name>/.env file are all the environment variables set?

I believe these should be the environment variables you'd need for the script to run.

https://github.com/Azure-Samples/azure-search-openai-demo-csharp/issues/154#issuecomment-1741401188

mikepugh commented 11 months ago

Yes the environment variables are all set. Thanks

Coruscate5 commented 11 months ago

FWIW - I had this issue due to tenant permissions settings, being an Owner on the environment objects fixed all the PrepareDocs subproject issues. I think this sample was created assuming you are GA in the tenant, sub owner isn't sufficient for tenant-wide settings like App Registrations