diff --git a/crates/factor-key-value-azure/src/lib.rs b/crates/factor-key-value-azure/src/lib.rs index 1e13cac35..949bfb186 100644 --- a/crates/factor-key-value-azure/src/lib.rs +++ b/crates/factor-key-value-azure/src/lib.rs @@ -1,6 +1,8 @@ use serde::Deserialize; use spin_factor_key_value::MakeKeyValueStore; -use spin_key_value_azure::KeyValueAzureCosmos; +use spin_key_value_azure::{ + KeyValueAzureCosmos, KeyValueAzureCosmosAuthOptions, KeyValueAzureCosmosRuntimeConfigOptions, +}; /// A key-value store that uses Azure Cosmos as the backend. pub struct AzureKeyValueStore; @@ -9,7 +11,7 @@ pub struct AzureKeyValueStore; #[derive(Deserialize)] pub struct AzureCosmosKeyValueRuntimeConfig { /// The authorization token for the Azure Cosmos DB account. - key: String, + key: Option, /// The Azure Cosmos DB account name. account: String, /// The Azure Cosmos DB database. @@ -30,11 +32,17 @@ impl MakeKeyValueStore for AzureKeyValueStore { &self, runtime_config: Self::RuntimeConfig, ) -> anyhow::Result { + let auth_options = match runtime_config.key { + Some(key) => KeyValueAzureCosmosAuthOptions::RuntimeConfigValues( + KeyValueAzureCosmosRuntimeConfigOptions::new(key), + ), + None => KeyValueAzureCosmosAuthOptions::Environmental, + }; KeyValueAzureCosmos::new( - runtime_config.key, runtime_config.account, runtime_config.database, runtime_config.container, + auth_options, ) } }