Failed to upload document Details: Error: 500: Internal Server Error
After deploying the web API to Azure, there was an error uploading the file: Failed to upload document Details: Error: 500: Internal Server Error
Category: Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer EventId: 2 SpanId: 7e2e32cb5d4200de TraceId: 51a29c23e281c02ef3bea59f1790dc02 ParentId: 0000000000000000 RequestId: 80000efb-0000-f400-b63f-84710c7967bb RequestPath: /importDocument
Connection ID "17582052946865032943", Request ID "80000efb-0000-f400-b63f-84710c7967bb": An unhandled exception was thrown by the application.
Exception:
Microsoft.Azure.Cosmos.CosmosException : Response status code does not indicate success: NotFound (404); Substatus: 0; ActivityId: 6bd35e5f-134b-433b-b48c-385e5c5537b5; Reason: (Message: {"Errors":["Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found"]}
ActivityId: 6bd35e5f-134b-433b-b48c-385e5c5537b5, Request URI: /apps/06083555-7b7a-4bf8-83bf-339684435fd8/services/3b15b24b-4e61-4334-9f3b-4a7262d573e7/partitions/18f75d11-6231-459b-9f20-f14979824f2e/replicas/133275438074978963s, RequestStats:
RequestStartTime: 2023-06-10T09:22:34.3022862Z, RequestEndTime: 2023-06-10T09:22:34.3022862Z, Number of regions attempted:1
{"systemHistory":[{"dateUtc":"2023-06-10T09:21:34.9711206Z","cpu":1.660,"memory":430070036.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0669,"availableThreads":32764,"minThreads":40,"maxThreads":32767},"numberOfOpenTcpConnection":3448},{"dateUtc":"2023-06-10T09:21:44.9813016Z","cpu":1.634,"memory":430059520.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0569,"availableThreads":32764,"minThreads":40,"maxThreads":32767},"numberOfOpenTcpConnection":3448},{"dateUtc":"2023-06-10T09:21:54.9914917Z","cpu":2.792,"memory":430035292.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.1166,"availableThreads":32764,"minThreads":40,"maxThreads":32767},"numberOfOpenTcpConnection":3449},{"dateUtc":"2023-06-10T09:22:05.0016668Z","cpu":2.076,"memory":430030176.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0445,"availableThreads":32764,"minThreads":40,"maxThreads":32767},"numberOfOpenTcpConnection":3447},{"dateUtc":"2023-06-10T09:22:15.0118980Z","cpu":1.167,"memory":430034688.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0849,"availableThreads":32763,"minThreads":40,"maxThreads":32767},"numberOfOpenTcpConnection":3447},{"dateUtc":"2023-06-10T09:22:25.0221353Z","cpu":1.062,"memory":430048956.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0474,"availableThreads":32764,"minThreads":40,"maxThreads":32767},"numberOfOpenTcpConnection":3447}]}
RequestStart: 2023-06-10T09:22:34.3022862Z; ResponseTime: 2023-06-10T09:22:34.3022862Z; StoreResult: StorePhysicalAddress: rntbd://10.0.0.19:11300/apps/06083555-7b7a-4bf8-83bf-339684435fd8/services/3b15b24b-4e61-4334-9f3b-4a7262d573e7/partitions/18f75d11-6231-459b-9f20-f14979824f2e/replicas/133275438074978963s, LSN: 12, GlobalCommittedLsn: 12, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#12, UsingLocalLSN: False, TransportException: null, BELatencyMs: 0.296, ActivityId: 6bd35e5f-134b-433b-b48c-385e5c5537b5, RetryAfterInMs: , TransportRequestTimeline: {"requestTimeline":[{"event": "Created", "startTimeUtc": "2023-06-10T09:22:34.3022862Z", "durationInMs": 0.018},{"event": "ChannelAcquisitionStarted", "startTimeUtc": "2023-06-10T09:22:34.3023042Z", "durationInMs": 0.0129},{"event": "Pipelined", "startTimeUtc": "2023-06-10T09:22:34.3023171Z", "durationInMs": 0.1023},{"event": "Transit Time", "startTimeUtc": "2023-06-10T09:22:34.3024194Z", "durationInMs": 0.949},{"event": "Received", "startTimeUtc": "2023-06-10T09:22:34.3033684Z", "durationInMs": 0.0761},{"event": "Completed", "startTimeUtc": "2023-06-10T09:22:34.3034445Z", "durationInMs": 0}],"serviceEndpointStats":{"inflightRequests":1,"openConnections":2},"connectionStats":{"waitforConnectionInit":"False","callsPendingReceive":0,"lastSendAttempt":"2023-06-10T09:22:33.0322686Z","lastSend":"2023-06-10T09:22:33.0322686Z","lastReceive":"2023-06-10T09:22:33.0322686Z"},"requestSizeInBytes":499,"responseMetadataSizeInBytes":135,"responseBodySizeInBytes":87};
ResourceType: Collection, OperationType: Read
RequestStart: 2023-06-10T09:22:34.3022862Z; ResponseTime: 2023-06-10T09:22:34.3022862Z; StoreResult: StorePhysicalAddress: rntbd://10.0.0.21:11300/apps/06083555-7b7a-4bf8-83bf-339684435fd8/services/3b15b24b-4e61-4334-9f3b-4a7262d573e7/partitions/18f75d11-6231-459b-9f20-f14979824f2e/replicas/133288265952632441s, LSN: 12, GlobalCommittedLsn: 12, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#12, UsingLocalLSN: False, TransportException: null, BELatencyMs: 0.267, ActivityId: 6bd35e5f-134b-433b-b48c-385e5c5537b5, RetryAfterInMs: , TransportRequestTimeline: {"requestTimeline":[{"event": "Created", "startTimeUtc": "2023-06-10T09:22:34.3022862Z", "durationInMs": 0.0063},{"event": "ChannelAcquisitionStarted", "startTimeUtc": "2023-06-10T09:22:34.3022925Z", "durationInMs": 0.0039},{"event": "Pipelined", "startTimeUtc": "2023-06-10T09:22:34.3022964Z", "durationInMs": 0.1281},{"event": "Transit Time", "startTimeUtc": "2023-06-10T09:22:34.3024245Z", "durationInMs": 0.9069},{"event": "Received", "startTimeUtc": "2023-06-10T09:22:34.3033314Z", "durationInMs": 0.0894},{"event": "Completed", "startTimeUtc": "2023-06-10T09:22:34.3034208Z", "durationInMs": 0}],"serviceEndpointStats":{"inflightRequests":1,"openConnections":2},"connectionStats":{"waitforConnectionInit":"False","callsPendingReceive":0,"lastSendAttempt":"2023-06-10T09:22:33.3122535Z","lastSend":"2023-06-10T09:22:33.3122535Z","lastReceive":"2023-06-10T09:22:33.3622907Z"},"requestSizeInBytes":499,"responseMetadataSizeInBytes":135,"responseBodySizeInBytes":87};
ResourceType: Collection, OperationType: Read
, SDK: Microsoft.Azure.Documents.Common/2.14.0, Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, Windows/10.0.14393 cosmos-netstandard-sdk/3.30.8);
at Microsoft.Azure.Cosmos.GatewayStoreClient.ParseResponseAsync(HttpResponseMessage responseMessage, JsonSerializerSettings serializerSettings, DocumentServiceRequest request)
at Microsoft.Azure.Cosmos.GatewayStoreClient.InvokeAsync(DocumentServiceRequest request, ResourceType resourceType, Uri physicalAddress, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.GatewayStoreModel.ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.GatewayStoreModel.ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.Routing.ClientCollectionCache.ReadCollectionAsync(String collectionLink, IDocumentClientRetryPolicy retryPolicyInstance, ITrace trace, IClientSideRequestStatistics clientSideRequestStatistics, CancellationToken cancellationToken)
at Microsoft.Azure.Documents.BackoffRetryUtility1.ExecuteRetryAsync[TParam,TPolicy](Func1 callbackMethod, Func3 callbackMethodWithParam, Func2 callbackMethodWithPolicy, TParam param, IRetryPolicy retryPolicy, IRetryPolicy1 retryPolicyWithArg, Func1 inBackoffAlternateCallbackMethod, Func2 inBackoffAlternateCallbackMethodWithPolicy, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action1 preRetryCallback)
at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException)
at Microsoft.Azure.Documents.BackoffRetryUtility1.ExecuteRetryAsync[TParam,TPolicy](Func1 callbackMethod, Func3 callbackMethodWithParam, Func2 callbackMethodWithPolicy, TParam param, IRetryPolicy retryPolicy, IRetryPolicy1 retryPolicyWithArg, Func1 inBackoffAlternateCallbackMethod, Func2 inBackoffAlternateCallbackMethodWithPolicy, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action1 preRetryCallback)
at Microsoft.Azure.Cosmos.Common.CollectionCache.<>c__DisplayClass10_0.<2.GetAsync(TKey key, TValue obsoleteValue, Func1 singleValueInitFunc, CancellationToken cancellationToken, Boolean forceRefresh)
at Microsoft.Azure.Cosmos.Common.CollectionCache.ResolveByNameAsync(String apiVersion, String resourceAddress, Boolean forceRefesh, ITrace trace, IClientSideRequestStatistics clientSideRequestStatistics, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.ContainerCore.GetCachedContainerPropertiesAsync(Boolean forceRefresh, ITrace trace, CancellationToken cancellationToken)
--- Cosmos Diagnostics ---{"Summary":{"GatewayCalls":{"(404, 0)":1}},"name":"UpsertItemAsync","start datetime":"2023-06-10T09:22:34.214Z","duration in milliseconds":128.6697,"data":{"Client Configuration":{"Client Created Time Utc":"2023-06-10T09:21:41.0359007Z","MachineId":"hashedMachineName:0fe7fbdb-5684-1831-d200-05da72e49356","NumberOfClientsCreated":3,"NumberOfActiveClients":3,"ConnectionMode":"Direct","User Agent":"cosmos-netstandard-sdk/3.34.0|3|X64|Microsoft Windows 10.0.14393|.NET 7.0.5|N|","ConnectionConfig":{"gw":"(cps:50, urto:10, p:False, httpf: False)","rntbd":"(cto: 5, icto: -1, mrpc: 30, mcpe: 65535, erd: True, pr: ReuseUnicastPort)","other":"(ed:False, be:False)"},"ConsistencyConfig":"(consistency: NotSet, prgns:[], apprgn: )","ProcessorCount":1}},"children":[{"name":"ItemSerialize","duration in milliseconds":22.5321},{"name":"Get PkValue From Stream","duration in milliseconds":76.9248,"children":[{"name":"Get Collection Cache","duration in milliseconds":0.0069},{"name":"Read Collection","duration in milliseconds":44.1749,"data":{"Client Side Request Stats":{"Id":"AggregatedClientSideRequestStatistics","ContactedReplicas":[],"RegionsContacted":[],"FailedReplicas":[],"AddressResolutionStatistics":[],"StoreResponseStatistics":[],"HttpResponseStats":[{"StartTimeUTC":"2023-06-10T09:22:34.3048575Z","DurationInMs":20.1123,"RequestUri":"https://cosmos-skwebapi-vhv2yzum7u2xs-eastus.documents.azure.com/dbs/CopilotChat/colls/chatmemorysources","ResourceType":"Collection","HttpMethod":"GET","ActivityId":"6bd35e5f-134b-433b-b48c-385e5c5537b5","StatusCode":"NotFound","ReasonPhrase":"Not Found"}]},"Exception Message":"Message: {"Errors":["Resource Not Found. Learn more: https:\/\/aka.ms\/cosmosdb-tsg-not-found"]}\r\nActivityId: 6bd35e5f-134b-433b-b48c-385e5c5537b5, Request URI: /apps/06083555-7b7a-4bf8-83bf-339684435fd8/services/3b15b24b-4e61-4334-9f3b-4a7262d573e7/partitions/18f75d11-6231-459b-9f20-f14979824f2e/replicas/133275438074978963s, RequestStats: \r\nRequestStartTime: 2023-06-10T09:22:34.3022862Z, RequestEndTime: 2023-06-10T09:22:34.3022862Z, Number of regions attempted:1\r\n{"systemHistory":[{"dateUtc":"2023-06-10T09:21:34.9711206Z","cpu":1.660,"memory":430070036.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0669,"availableThreads":32764,"minThreads":40,"maxThreads":32767},"numberOfOpenTcpConnection":3448},{"dateUtc":"2023-06-10T09:21:44.9813016Z","cpu":1.634,"memory":430059520.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0569,"availableThreads":32764,"minThreads":40,"maxThreads":32767},"numberOfOpenTcpConnection":3448},{"dateUtc":"2023-06-10T09:21:54.9914917Z","cpu":2.792,"memory":430035292.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.1166,"availableThreads":32764,"minThreads":40,"maxThreads":32767},"numberOfOpenTcpConnection":3449},{"dateUtc":"2023-06-10T09:22:05.0016668Z","cpu":2.076,"memory":430030176.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0445,"availableThreads":32764,"minThreads":40,"maxThreads":32767},"numberOfOpenTcpConnection":3447},{"dateUtc":"2023-06-10T09:22:15.0118980Z","cpu":1.167,"memory":430034688.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0849,"availableThreads":32763,"minThreads":40,"maxThreads":32767},"numberOfOpenTcpConnection":3447},{"dateUtc":"2023-06-10T09:22:25.0221353Z","cpu":1.062,"memory":430048956.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0474,"availableThreads":32764,"minThreads":40,"maxThreads":32767},"numberOfOpenTcpConnection":3447}]}\r\nRequestStart: 2023-06-10T09:22:34.3022862Z; ResponseTime: 2023-06-10T09:22:34.3022862Z; StoreResult: StorePhysicalAddress: rntbd://10.0.0.19:11300/apps/06083555-7b7a-4bf8-83bf-339684435fd8/services/3b15b24b-4e61-4334-9f3b-4a7262d573e7/partitions/18f75d11-6231-459b-9f20-f14979824f2e/replicas/133275438074978963s, LSN: 12, GlobalCommittedLsn: 12, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#12, UsingLocalLSN: False, TransportException: null, BELatencyMs: 0.296, ActivityId: 6bd35e5f-134b-433b-b48c-385e5c5537b5, RetryAfterInMs: , TransportRequestTimeline: {"requestTimeline":[{"event": "Created", "startTimeUtc": "2023-06-10T09:22:34.3022862Z", "durationInMs": 0.018},{"event": "ChannelAcquisitionStarted", "startTimeUtc": "2023-06-10T09:22:34.3023042Z", "durationInMs": 0.0129},{"event": "Pipelined", "startTimeUtc": "2023-06-10T09:22:34.3023171Z", "durationInMs": 0.1023},{"event": "Transit Time", "startTimeUtc": "2023-06-10T09:22:34.3024194Z", "durationInMs": 0.949},{"event": "Received", "startTimeUtc": "2023-06-10T09:22:34.3033684Z", "durationInMs": 0.0761},{"event": "Completed", "startTimeUtc": "2023-06-10T09:22:34.3034445Z", "durationInMs": 0}],"serviceEndpointStats":{"inflightRequests":1,"openConnections":2},"connectionStats":{"waitforConnectionInit":"False","callsPendingReceive":0,"lastSendAttempt":"2023-06-10T09:22:33.0322686Z","lastSend":"2023-06-10T09:22:33.0322686Z","lastReceive":"2023-06-10T09:22:33.0322686Z"},"requestSizeInBytes":499,"responseMetadataSizeInBytes":135,"responseBodySizeInBytes":87};\r\n ResourceType: Collection, OperationType: Read\r\nRequestStart: 2023-06-10T09:22:34.3022862Z; ResponseTime: 2023-06-10T09:22:34.3022862Z; StoreResult: StorePhysicalAddress: rntbd://10.0.0.21:11300/apps/06083555-7b7a-4bf8-83bf-339684435fd8/services/3b15b24b-4e61-4334-9f3b-4a7262d573e7/partitions/18f75d11-6231-459b-9f20-f14979824f2e/replicas/133288265952632441s, LSN: 12, GlobalCommittedLsn: 12, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#12, UsingLocalLSN: False, TransportException: null, BELatencyMs: 0.267, ActivityId: 6bd35e5f-134b-433b-b48c-385e5c5537b5, RetryAfterInMs: , TransportRequestTimeline: {"requestTimeline":[{"event": "Created", "startTimeUtc": "2023-06-10T09:22:34.3022862Z", "durationInMs": 0.0063},{"event": "ChannelAcquisitionStarted", "startTimeUtc": "2023-06-10T09:22:34.3022925Z", "durationInMs": 0.0039},{"event": "Pipelined", "startTimeUtc": "2023-06-10T09:22:34.3022964Z", "durationInMs": 0.1281},{"event": "Transit Time", "startTimeUtc": "2023-06-10T09:22:34.3024245Z", "durationInMs": 0.9069},{"event": "Received", "startTimeUtc": "2023-06-10T09:22:34.3033314Z", "durationInMs": 0.0894},{"event": "Completed", "startTimeUtc": "2023-06-10T09:22:34.3034208Z", "durationInMs": 0}],"serviceEndpointStats":{"inflightRequests":1,"openConnections":2},"connectionStats":{"waitforConnectionInit":"False","callsPendingReceive":0,"lastSendAttempt":"2023-06-10T09:22:33.3122535Z","lastSend":"2023-06-10T09:22:33.3122535Z","lastReceive":"2023-06-10T09:22:33.3622907Z"},"requestSizeInBytes":499,"responseMetadataSizeInBytes":135,"responseBodySizeInBytes":87};\r\n ResourceType: Collection, OperationType: Read\r\n, SDK: Microsoft.Azure.Documents.Common/2.14.0, Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, Windows/10.0.14393 cosmos-netstandard-sdk/3.30.8"}}]}]}
Getting the same error. Logs show /importdocument endpoint gives a 404 NotFound
Can you please double check that you have a provisioned CosmosDB instance and that it is accessible by your web app?
From the logs above, the 404 seems to be coming from the CosmosDB client.
I would expect a similar error just chatting with the bot, independent of uploading documents also if your CosmosDB instance is not configured/accessible by the webapi
Can you please double check that you have a provisioned CosmosDB instance and that it is accessible by your web app?
From the logs above, the 404 seems to be coming from the CosmosDB client.
I would expect a similar error just chatting with the bot, independent of uploading documents also if your CosmosDB instance is not configured/accessible by the webapi
My cosmosDB was created through "webAPI\DeploymentTemplates\sk-existing-openai.json" and was not pre configured. It's normal for me to try chatting with the robot, and I can also see messages in Cosmosdb.
Figured out the issue. It's that the creation of the chatmemorysources Cosmos db container is missing from the bicep template:
https://github.com/microsoft/semantic-kernel/blob/b31e36ba4f655c7df5f382269573e63229c964e6/samples/apps/copilot-chat-app/deploy/main.bicep#L516-L633
As well as the web app config: https://github.com/microsoft/semantic-kernel/blob/b31e36ba4f655c7df5f382269573e63229c964e6/samples/apps/copilot-chat-app/deploy/main.bicep#L195-L210
I manually created the chatmemorysources container (with partition key /id) in Cosmos Db:
And updated the web app config:
Now the document upload is working when the app is deployed to Azure.