RegisterSemanticSkills and RegisterNativeSkills throw exception on Azure App Service
Describe the bug A clear and concise description of what the bug is.
Working well locally, but throws below exception when deployed to Azure Web Service.
{
"title": "One or more model validation errors occurred.",
"status": 500,
"detail": "Microsoft.SemanticKernel.KernelException: ServiceNotFound: Text completion service not available\r\n at Microsoft.SemanticKernel.KernelConfig.GetTextCompletionServiceIdOrDefault(String serviceId)\r\n at Microsoft.SemanticKernel.Kernel.GetService[T](String name)\r\n at Microsoft.SemanticKernel.Kernel.<CreateSemanticFunction>b__33_0()\r\n at Microsoft.SemanticKernel.Orchestration.SKFunction.SetAIService(Func`1 serviceFactory)\r\n at Microsoft.SemanticKernel.Kernel.CreateSemanticFunction(String skillName, String functionName, SemanticFunctionConfig functionConfig)\r\n at Microsoft.SemanticKernel.Kernel.RegisterSemanticFunction(String skillName, String functionName, SemanticFunctionConfig functionConfig)\r\n at Microsoft.SemanticKernel.InlineFunctionsDefinitionExtension.CreateSemanticFunction(IKernel kernel, String promptTemplate, PromptTemplateConfig config, String functionName, String skillName)\r\n at Microsoft.SemanticKernel.InlineFunctionsDefinitionExtension.CreateSemanticFunction(IKernel kernel, String promptTemplate, String functionName, String skillName, String description, Int32 maxTokens, Double temperature, Double topP, Double presencePenalty, Double frequencyPenalty, IEnumerable`1 stopSequences)\r\n at Microsoft.SemanticKernel.CoreSkills.ConversationSummarySkill..ctor(IKernel kernel)\r\n at CloudHospital.KernelApi.Extensions.FunctionLoadingExtensions.RegisterNativeSkills(IKernel kernel, ICognitiveSearchConnector connector, ILogger logger) in C:\\Users\\hyuno\\Documents\\GitHub\\iCloudHospital\\CloudHospital.Api\\CloudHospital.KernelApi\\Extensions\\FunctionLoadingExtensions.cs:line 38\r\n at CloudHospital.KernelApi.Contracts.V1.SemanticKernelController.Skills(Kernel kernel, Ask ask, String skillName, String functionName) in C:\\Users\\hyuno\\Documents\\GitHub\\iCloudHospital\\CloudHospital.Api\\CloudHospital.KernelApi\\Contracts\\V1\\SemanticKernelController.cs:line 53\r\n at lambda_method34(Closure, Object)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n--- End of stack trace from previous location ---\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)",
"instance": "/api/v1/semantickernel/skills/AIChatSkill/functions/CHChat",
"traceId": "00-cd90d1d8c592552e198b876edd6858b7-af3e3eddbd53e4b5-00",
"errors": {
"message": [
"ServiceNotFound: Text completion service not available"
]
}
}
Tried remote debugging and the code just spit above exception at
skill[functionName] = kernel.RegisterSemanticFunction(skillDirectoryName, functionName, functionConfig);
SematicKernel/KenelExtensions/ImportSemanticSkillFromDirectory.cs line 97
To Reproduce Steps to reproduce the behavior:
- Deploy CopilotChatApi to Azure
- Try post SemanticKernelController endpoint
- See error
Expected behavior A clear and concise description of what you expected to happen.
This just run really well llocally. Tried to find a root cause but failed.
First, Skills directory were not uploaded so I added CopyToOutputDirectory and those files are all uploaded to destination.
<ItemGroup>
<None Update="SemanticSkillsDirectory\*\*\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Screenshots


Desktop (please complete the following information):
- OS: Windows
- IDE: Visual Studio
- NuGet Package Version [0.11.146.1-preview]
Additional context I don't understand why SemanticSkills are form of txt files and config that had to invoke file IO Can't we just load this from DB?
Here's some detailed exception from profiler.
Microsoft.SemanticKernel.KernelException
``` Stack Trace 1 microsoft.semantickernel!Microsoft.SemanticKernel.KernelConfig.GetTextCompletionServiceIdOrDefaultmicrosoft.semantickernel!Microsoft.SemanticKernel.Kernel.GetServicemicrosoft.semantickernel!Microsoft.SemanticKernel.Kernel.System.IO.IOException
``` Stack Trace 1 system.net.sockets!System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs::ThrowExceptionsystem.net.sockets.il!System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSourceStack Trace 2
system.net.security.il!System.Net.Security.SslStream+<ReadAsyncInternal>d__1591[System.Net.Security.AsyncReadWriteAdapter].MoveNextsystem.net.sockets!System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs::ThrowExceptionsystem.net.sockets.il!System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResultsystem.net.security.il!System.Net.Security.SslStream+<ReadAsyncInternal>d__1591[System.Net.Security.AsyncReadWriteAdapter].MoveNextsystem.private.corelib.il!System.Threading.ExecutionContext.RunInternalsystem.net.sockets.il!System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.InvokeContinuationsystem.net.sockets.il!System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.OnCompletedsystem.net.sockets.il!System.Net.Sockets.SocketAsyncEventArgs+<>c.<.cctor>b__176_0system.private.corelib.il!System.Threading.ThreadPoolTypedWorkItemQueue`2[System.Threading.PortableThreadPool+IOCompletionPoller+Event,System.Threading.PortableThreadPool+IOCompletionPoller+Callback].System.Threading.IThreadPoolWorkItem.Executesystem.private.corelib.il!System.Threading.ThreadPoolWorkQueue.Dispatchsystem.private.corelib!System.Threading.PortableThreadPool+WorkerThread::WorkerThreadStart
Stack Trace 3
system.private.corelib.il!System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throwsystem.private.corelib!System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore1[System.Int32]::ThrowForFailedGetResultsystem.private.corelib.il!System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder1+StateMachineBox1[System.Int32,System.Net.Security.SslStream+<ReadAsyncInternal>d__1591[System.Net.Security.AsyncReadWriteAdapter]].System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResultsystem.net.http.il!System.Net.Http.HttpConnection+<<CheckUsabilityOnScavenge>g__ReadAheadWithZeroByteReadAsync|44_0>d.MoveNextsystem.private.corelib.il!System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[System.Int32,System.Net.Http.HttpConnection+<<CheckUsabilityOnScavenge>g__ReadAheadWithZeroByteReadAsync|44_0>d].ExecutionContextCallbacksystem.private.corelib.il!System.Threading.ExecutionContext.RunInternalsystem.private.corelib.il!System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[System.Int32,System.Net.Http.HttpConnection+<<CheckUsabilityOnScavenge>g__ReadAheadWithZeroByteReadAsync|44_0>d].MoveNextsystem.private.corelib.il!System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[System.Int32,System.Net.Http.HttpConnection+<<CheckUsabilityOnScavenge>g__ReadAheadWithZeroByteReadAsync|44_0>d].MoveNextsystem.net.security.il!System.Net.Security.SslStream+<ReadAsyncInternal>d__1591[System.Net.Security.AsyncReadWriteAdapter].MoveNextsystem.net.security.il!System.Net.Security.SslStream+<ReadAsyncInternal>d__1591[System.Net.Security.AsyncReadWriteAdapter].MoveNextsystem.net.sockets!System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs::ThrowExceptionsystem.net.sockets.il!System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResultsystem.net.security.il!System.Net.Security.SslStream+<ReadAsyncInternal>d__1591[System.Net.Security.AsyncReadWriteAdapter].MoveNextsystem.private.corelib.il!System.Threading.ExecutionContext.RunInternalsystem.net.sockets.il!System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.InvokeContinuationsystem.net.sockets.il!System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.OnCompletedsystem.net.sockets.il!System.Net.Sockets.SocketAsyncEventArgs+<>c.<.cctor>b__176_0system.private.corelib.il!System.Threading.ThreadPoolTypedWorkItemQueue2[System.Threading.PortableThreadPool+IOCompletionPoller+Event,System.Threading.PortableThreadPool+IOCompletionPoller+Callback].System.Threading.IThreadPoolWorkItem.Executesystem.private.corelib.il!System.Threading.ThreadPoolWorkQueue.Dispatchsystem.private.corelib!System.Threading.PortableThreadPool+WorkerThread::WorkerThreadStart
</details>
@hathind-ms Could we look into this?
This issue has gone after downgrade to net standard 2.0 Not 100% sure of this was related though
Lots of other changes have made it in during the past few days.
Closing for now since it can't be reproduced anymore.
Feel free to re-open if it occurs again.