kernel-memory icon indicating copy to clipboard operation
kernel-memory copied to clipboard

[Question] Access denied with valid Endpoint and APIKey

Open coryisakson opened this issue 1 year ago • 1 comments

Context / Scenario

I am running the service directly from VS Code. I have created an appsettings.Developmnet.json file with the desired configuration. When I upload a document the pipeline starts processing and then fails. Here is a partial configuration where I have removed my service name and API key, but I have copied them directly from the Azure portal.

"Services": {
  "SimpleFileStorage": {
    "Directory": "simple-file-storage"
  },
  "AzureOpenAIEmbedding": {
    "APIType": "EmbeddingGeneration",
    "Auth": "ApiKey",
    "Endpoint": "https://[secret].openai.azure.com/",
    "Deployment": "text-embedding-ada-002",
    "APIKey": "[secret of course]"
  },

What happened?

No content added to the index.

Importance

I cannot use Kernel Memory

Platform, Language, Versions

Windows, C#, Commit 6d516d7

Relevant log output

---> Azure.RequestFailedException: Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource.
Status: 401 (PermissionDenied)
ErrorCode: 401

Content:
{"error":{"code":"401","message":"Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource."}}

Headers:
apim-request-id: REDACTED
Date: Tue, 27 Feb 2024 20:09:01 GMT
Content-Length: 224
Content-Type: application/json

   at Azure.Core.HttpPipelineExtensions.ProcessMessageAsync(HttpPipeline pipeline, HttpMessage message, RequestContext requestContext, CancellationToken cancellationToken)
   at Azure.AI.OpenAI.OpenAIClient.GetEmbeddingsAsync(EmbeddingsOptions embeddingsOptions, CancellationToken cancellationToken)
   at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.RunRequestAsync[T](Func`1 request)
   --- End of inner exception stack trace ---
   at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.RunRequestAsync[T](Func`1 request)
   at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.GetEmbeddingsAsync(IList`1 data, Kernel kernel, CancellationToken cancellationToken)
   at Microsoft.SemanticKernel.AI.Embeddings.TextEmbeddingGenerationExtensions.GenerateEmbeddingAsync(ITextEmbeddingGenerationService generator, String text, CancellationToken cancellationToken)
   at Microsoft.KernelMemory.Handlers.GenerateEmbeddingsHandler.InvokeAsync(DataPipeline pipeline, CancellationToken cancellationToken)
   at Microsoft.KernelMemory.Pipeline.InProcessPipelineOrchestrator.RunPipelineAsync(DataPipeline pipeline, CancellationToken cancellationToken)
   at Microsoft.KernelMemory.Pipeline.BaseOrchestrator.ImportDocumentAsync(String index, DocumentUploadRequest uploadRequest, CancellationToken cancellationToken)

coryisakson avatar Feb 27 '24 21:02 coryisakson

@coryisakson I suspect the code is not picking the settings from your configuration file. I could be due to the typo appsettings.Developmnet.json => appsettings.Development.json or because the ASPNETCORE_ENVIRONMENT env var is not set to Development.

If you're running the code in Azure, ASPNETCORE_ENVIRONMENTmight be set to Production in which case the config filename should be appsettings.Production.json.

dluc avatar Feb 28 '24 01:02 dluc