Skip to content

Commit 4e5e0cd

Browse files
committed
Read blobs
Signed-off-by: itowlson <[email protected]>
1 parent 0432cd5 commit 4e5e0cd

File tree

30 files changed

+3318
-1119
lines changed

30 files changed

+3318
-1119
lines changed

Cargo.lock

Lines changed: 1280 additions & 1112 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ members = [
118118
[workspace.dependencies]
119119
anyhow = "1"
120120
async-trait = "0.1"
121+
azure_core = "0.21.0"
122+
azure_data_cosmos = "0.21.0"
123+
azure_identity = "0.21.0"
124+
azure_security_keyvault = "0.21.0"
125+
azure_storage = "0.21.0"
126+
azure_storage_blobs = "0.21.0"
121127
bytes = "1"
122128
conformance-tests = { git = "https://github.com/fermyon/conformance-tests", rev = "ecd22a45bcc5c775a56c67689a89aa4005866ac0" }
123129
dirs = "5.0"

crates/blobstore-azure/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "spin-blobstore-azure"
3+
version.workspace = true
4+
authors.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
rust-version.workspace = true
10+
11+
[dependencies]
12+
anyhow = { workspace = true }
13+
azure_core = { workspace = true }
14+
azure_storage = { workspace = true }
15+
azure_storage_blobs = { workspace = true }
16+
futures = { workspace = true }
17+
serde = { workspace = true }
18+
spin-core = { path = "../core" }
19+
spin-factor-blobstore = { path = "../factor-blobstore" }
20+
tokio = { workspace = true }
21+
tokio-stream = "0.1.16"
22+
tokio-util = "0.7.12"
23+
wasmtime-wasi = { workspace = true }
24+
25+
[lints]
26+
workspace = true

crates/blobstore-azure/src/lib.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
mod store;
2+
3+
use serde::Deserialize;
4+
use spin_factor_blobstore::runtime_config::spin::MakeBlobStore;
5+
use store::{
6+
BlobStoreAzureBlob,
7+
// KeyValueAzureCosmos, KeyValueAzureCosmosAuthOptions, KeyValueAzureCosmosRuntimeConfigOptions,
8+
};
9+
10+
/// A key-value store that uses Azure Cosmos as the backend.
11+
#[derive(Default)]
12+
pub struct AzureBlobStore {
13+
_priv: (),
14+
}
15+
16+
impl AzureBlobStore {
17+
/// Creates a new `AzureBlobStore`.
18+
pub fn new() -> Self {
19+
Self::default()
20+
}
21+
}
22+
23+
/// Runtime configuration for the Azure Cosmos key-value store.
24+
#[derive(Deserialize)]
25+
pub struct AzureBlobStoreRuntimeConfig {
26+
/// The authorization token for the Azure blob storage account.
27+
key: Option<String>,
28+
/// The Azure blob storage account name.
29+
account: String,
30+
}
31+
32+
impl MakeBlobStore for AzureBlobStore {
33+
const RUNTIME_CONFIG_TYPE: &'static str = "azure_blob";
34+
35+
type RuntimeConfig = AzureBlobStoreRuntimeConfig;
36+
37+
type ContainerManager = BlobStoreAzureBlob;
38+
39+
fn make_store(
40+
&self,
41+
runtime_config: Self::RuntimeConfig,
42+
) -> anyhow::Result<Self::ContainerManager> {
43+
let auth = match &runtime_config.key {
44+
Some(key) => store::BlobStoreAzureAuthOptions::RuntimeConfigValues(store::BlobStoreAzureRuntimeConfigOptions::new(runtime_config.account.clone(), key.clone())),
45+
None => store::BlobStoreAzureAuthOptions::Environmental,
46+
};
47+
48+
49+
// let account = &runtime_config.account;
50+
// let key = &runtime_config.key;
51+
52+
// let credentials = azure_storage::prelude::StorageCredentials::access_key(account, key);
53+
// let client = azure_storage_blobs::prelude::ClientBuilder::new(account, credentials);
54+
55+
let blob_store = BlobStoreAzureBlob::new(auth)?;
56+
Ok(blob_store)
57+
}
58+
}

0 commit comments

Comments
 (0)