Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Bug: System.ClientModel.ClientResultException: 'HTTP 401 (PermissionDenied) Principal does not have access to API/Operation.' when running VectorStoreRAG.csproj #10020

Open
radrad opened this issue Dec 19, 2024 · 0 comments
Assignees
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code

Comments

@radrad
Copy link

radrad commented Dec 19, 2024

Semanatic kernel version: "1.32.0.0"

Z:\semantic-kernel\dotnet\src\Connectors\Connectors.OpenAI\Core\ClientCore.cs

Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.RunRequestAsync(System.Func<System.Threading.Tasks.Task>) in ClientCore.cs

Error: return await request.Invoke().ConfigureAwait(false);

{"HTTP 401 (PermissionDenied)\r\n\r\nPrincipal does not have access to API/Operation."} | System.ClientModel.ClientResultException

This is a part of header for post message I managed to see.
I don't know where it the pipeline a token is added.

{Method: POST, RequestUri: 'https://.openai.azure.com/openai/deployments//chat/completions?api-version=2024-10-01-preview', Version: 1.1, Content: System.ClientModel.Primitives.HttpClientPipelineTransport+HttpPipelineRequest+MessageBodyAdapter, Headers:
{
Accept: application/json
User-Agent: Semantic-Kernel azsdk-net-AI.OpenAI/2.1.0-beta.2 (.NET 8.0.11; Microsoft Windows 10.0.22000)
x-ms-client-request-id: 3245c4e1-4d0c-94c2-234234
Content-Type: application/json
}}

I did run az login prior to running code. Both of these don't work. Below you can see in the image assigned [Cognitive Services Contributor] and even [owner] to my azure account. So I exhausted my ideas.

    kernelBuilder.AddAzureOpenAIChatCompletion(
        appConfig.AzureOpenAIConfig.ChatDeploymentName,
        appConfig.AzureOpenAIConfig.Endpoint,
        new AzureCliCredential());

    kernelBuilder.AddAzureOpenAIChatCompletion(
        appConfig.AzureOpenAIConfig.ChatDeploymentName,
        appConfig.AzureOpenAIConfig.Endpoint,
        new DefaultAzureCredential());

When I tried using another overrinden method with appConfig.AzureOpenAIConfig.ApiKey instead it did work. But I would like to avoid using api keys.

Image

How I am supposed to run this code?

@radrad radrad added the bug Something isn't working label Dec 19, 2024
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Dec 19, 2024
@github-actions github-actions bot changed the title Bug: System.ClientModel.ClientResultException: 'HTTP 401 (PermissionDenied) Principal does not have access to API/Operation.' when running VectorStoreRAG.csproj .Net: Bug: System.ClientModel.ClientResultException: 'HTTP 401 (PermissionDenied) Principal does not have access to API/Operation.' when running VectorStoreRAG.csproj Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code
Projects
Status: No status
Development

No branches or pull requests

3 participants