public static async Task SetupTransientTenant(FeatureContext context) { // This needs to run after the ServiceProvider has been constructed IServiceProvider provider = ContainerBindings.GetServiceProvider(context); ITenantProvider tenantProvider = provider.GetRequiredService <ITenantProvider>(); // In order to ensure the Cosmos aspects of the Tenancy setup are fully configured, we need to resolve // the ITenantCosmosContainerFactory, which triggers setting default config to the root tenant. // HACK: This is a hack until we can come up with a better way of handling deferred initialisation. provider.GetRequiredService <ITenantCosmosContainerFactory>(); ITenant rootTenant = tenantProvider.Root; ITenant transientTenant = await tenantProvider.CreateChildTenantAsync(rootTenant.Id).ConfigureAwait(false); CosmosConfiguration config = rootTenant.GetDefaultCosmosConfiguration() ?? new CosmosConfiguration(); config.DatabaseName = "endjinspecssharedthroughput"; config.DisableTenantIdPrefix = true; transientTenant.SetDefaultCosmosConfiguration(config); await tenantProvider.UpdateTenantAsync(transientTenant).ConfigureAwait(false); context.Set(transientTenant); }