Web API addCustomer service faced error when connecting Azure Cosmos DB
Ying Kit Li
1
Reputation point
System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Azure.Cosmos.CosmosClient' while attempting to activate 'CosmosWebAPI.Controllers.CosmosDbService'.
I got the above exceptions when running the below api service in local swagger site:
[Route("/AddCustomer")]
HttpPost]
public async Task AddAsync(Customer item) {
await _container.CreateItemAsync(item, new PartitionKey(item.Id));
}
Please help.
Sign in to answer