in src/WebJobs.Extensions.CosmosDB/Config/DefaultCosmosDBServiceFactory.cs [38:66]
private CosmosConnectionInformation ResolveConnectionInformation(string connection)
{
var connectionSetting = connection ?? Constants.DefaultConnectionStringName;
IConfigurationSection connectionSection = WebJobsConfigurationExtensions.GetWebJobsConnectionStringSection(this._configuration, connectionSetting);
if (!connectionSection.Exists())
{
// Not found
throw new InvalidOperationException($"Cosmos DB connection configuration '{connectionSetting}' does not exist. " +
$"Make sure that it is a defined App Setting.");
}
if (!string.IsNullOrWhiteSpace(connectionSection.Value))
{
return new CosmosConnectionInformation(connectionSection.Value);
}
else
{
string accountEndpoint = connectionSection["accountEndpoint"];
if (string.IsNullOrWhiteSpace(accountEndpoint))
{
// Not found
throw new InvalidOperationException($"Connection should have an 'accountEndpoint' property or be a " +
$"string representing a connection string.");
}
TokenCredential credential = _componentFactory.CreateTokenCredential(connectionSection);
return new CosmosConnectionInformation(accountEndpoint, credential);
}
}