azure-search-openai-demo-csharp icon indicating copy to clipboard operation
azure-search-openai-demo-csharp copied to clipboard

Authorization failed message on prepdocs.ps1

Open mikepugh opened this issue 2 years ago • 3 comments
trafficstars

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.<<GetIndexNamesAsync>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.

mikepugh avatar Oct 16 '23 14:10 mikepugh

@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

luisquintanilla avatar Oct 16 '23 17:10 luisquintanilla

Yes the environment variables are all set. Thanks

mikepugh avatar Oct 16 '23 18:10 mikepugh

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

Coruscate5 avatar Oct 25 '23 22:10 Coruscate5