Skip to content

Commit f96ab53

Browse files
[Storage] azure_storage_blob release documentation nits (#2442)
1 parent b59245f commit f96ab53

File tree

6 files changed

+91
-65
lines changed

6 files changed

+91
-65
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/storage/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

sdk/storage/azure_storage_blob/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ rust-version.workspace = true
1212
[dependencies]
1313
async-trait.workspace = true
1414
azure_core = { workspace = true, features = ["xml"] }
15-
azure_storage_common = { version = "0.1.0", path = "../azure_storage_common" }
1615
serde.workspace = true
1716
time.workspace = true
1817
typespec_client_core = { workspace = true, features = ["derive"] }

sdk/storage/azure_storage_blob/README.md

Lines changed: 84 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ cargo add azure_storage_blob
1818

1919
* You must have an [Azure subscription] and an [Azure storage account] to use this package.
2020

21-
22-
2321
### Create a storage account
22+
2423
If you wish to create a new storage account, you can use the
2524
[Azure Portal], [Azure PowerShell], or [Azure CLI]:
26-
```bash
25+
26+
```sh
2727
# Create a new resource group to hold the storage account -
2828
# if using an existing resource group, skip this step
2929
az group create --name my-resource-group --location westus2
@@ -35,85 +35,109 @@ az storage account create -n my-storage-account-name -g my-resource-group
3535
#### Authenticate the client
3636

3737
In order to interact with the Azure Blob Storage service, you'll need to create an instance of a client, `BlobClient`, `BlobContainerClient`, or `BlobServiceClient`. The [Azure Identity] library makes it easy to add Microsoft Entra ID support for authenticating Azure SDK clients with their corresponding Azure services:
38-
```rust
39-
use azure_storage_blob::BlobClient;
38+
39+
```rust no_run
40+
use azure_storage_blob::{BlobClient, BlobClientOptions};
4041
use azure_identity::DefaultAzureCredential;
4142

42-
// Create a BlobClient that will authenticate through Microsoft Entra ID
43-
let credential = DefaultAzureCredential::new()?;
44-
let blob_client = BlobClient::new(
45-
"https://<storage_account_name>.blob.core.windows.net/", // endpoint
46-
"container_name".to_string(), // container name
47-
"blob_name".to_string(), // blob name
48-
credential, // credential
49-
Some(BlobClientOptions::default()), // BlobClient options
50-
)?;
43+
#[tokio::main]
44+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
45+
// Create a BlobClient that will authenticate through Microsoft Entra ID
46+
let credential = DefaultAzureCredential::new()?;
47+
let blob_client = BlobClient::new(
48+
"https://<storage_account_name>.blob.core.windows.net/", // endpoint
49+
"container_name".to_string(), // container name
50+
"blob_name".to_string(), // blob name
51+
credential, // credential
52+
Some(BlobClientOptions::default()), // BlobClient options
53+
)?;
54+
Ok(())
55+
}
5156
```
5257

5358
#### Permissions
59+
5460
You may need to specify RBAC roles to access Blob Storage via Microsoft Entra ID. Please see [Assign an Azure role for access to blob data] for more details.
5561

5662
## Examples
5763

5864
### Create `BlobClient`
59-
```rust
60-
use azure_storage_blob::BlobClient;
65+
66+
```rust no_run
67+
use azure_storage_blob::{BlobClient, BlobClientOptions};
6168
use azure_identity::DefaultAzureCredential;
6269

63-
// Create a BlobClient that will authenticate through Microsoft Entra ID
64-
let credential = DefaultAzureCredential::new()?;
65-
let blob_client = BlobClient::new(
66-
"https://<storage_account_name>.blob.core.windows.net/", // endpoint
67-
"container_name".to_string(), // container name
68-
"blob_name".to_string(), // blob name
69-
credential, // credential
70-
Some(BlobClientOptions::default()), // BlobClient options
71-
)?;
70+
#[tokio::main]
71+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
72+
// Create a BlobClient that will authenticate through Microsoft Entra ID
73+
let credential = DefaultAzureCredential::new()?;
74+
let blob_client = BlobClient::new(
75+
"https://<storage_account_name>.blob.core.windows.net/", // endpoint
76+
"container_name".to_string(), // container name
77+
"blob_name".to_string(), // blob name
78+
credential, // credential
79+
Some(BlobClientOptions::default()), // BlobClient options
80+
)?;
81+
Ok(())
82+
}
7283
```
84+
7385
### Upload Blob
74-
```rust
75-
use azure_storage_blob::BlobClient;
86+
87+
```rust no_run
88+
use azure_core::http::RequestContent;
89+
use azure_storage_blob::{BlobClient, BlobClientOptions};
7690
use azure_identity::DefaultAzureCredential;
7791

78-
let credential = DefaultAzureCredential::new()?;
79-
let blob_client = BlobClient::new(
80-
"https://<storage_account_name>.blob.core.windows.net/",
81-
"container_name".to_string(),
82-
"blob_name".to_string(),
83-
credential,
84-
Some(BlobClientOptions::default()),
85-
)?;
86-
87-
blob_client
88-
.upload(
89-
RequestContent::from(data.to_vec()), // data
90-
false, // overwrite
91-
u64::try_from(data.len())?, // content length
92-
None, // upload options
93-
)
94-
.await?;
92+
#[tokio::main]
93+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
94+
let credential = DefaultAzureCredential::new()?;
95+
let blob_client = BlobClient::new(
96+
"https://<storage_account_name>.blob.core.windows.net/",
97+
"container_name".to_string(),
98+
"blob_name".to_string(),
99+
credential,
100+
Some(BlobClientOptions::default()),
101+
)?;
102+
103+
let data = b"hello world";
104+
blob_client
105+
.upload(
106+
RequestContent::from(data.to_vec()), // data
107+
false, // overwrite
108+
u64::try_from(data.len())?, // content length
109+
None, // upload options
110+
)
111+
.await?;
112+
Ok(())
113+
}
95114
```
96115

97116
### Get Blob Properties
98-
```rust
99-
use azure_storage_blob::BlobClient;
117+
118+
```rust no_run
119+
use azure_storage_blob::{BlobClient, BlobClientOptions};
100120
use azure_identity::DefaultAzureCredential;
101121

102-
let credential = DefaultAzureCredential::new()?;
103-
let blob_client = BlobClient::new(
104-
"https://<storage_account_name>.blob.core.windows.net/",
105-
"container_name".to_string(),
106-
"blob_name".to_string(),
107-
credential,
108-
Some(BlobClientOptions::default()),
109-
)?;
110-
let blob_properties = blob_client.get_properties(
111-
None // get properties options
112-
)
113-
.await?;
122+
#[tokio::main]
123+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
124+
125+
let credential = DefaultAzureCredential::new()?;
126+
let blob_client = BlobClient::new(
127+
"https://<storage_account_name>.blob.core.windows.net/",
128+
"container_name".to_string(),
129+
"blob_name".to_string(),
130+
credential,
131+
Some(BlobClientOptions::default()),
132+
)?;
133+
let blob_properties = blob_client.get_properties(
134+
None // get properties options
135+
)
136+
.await?;
137+
Ok(())
138+
}
114139
```
115140

116-
117141
## Next steps
118142

119143
### Provide feedback
@@ -138,7 +162,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
138162
[Azure Identity]: https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/identity/azure_identity
139163
[API reference documentation]: https://docs.rs/crate/azure_storage_blob/latest
140164
[Package (crates.io)]: https://crates.io/crates/azure_storage_blob
141-
[Source code]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
165+
[Source code]: https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/storage/azure_storage_blob
142166
[REST API documentation]: https://learn.microsoft.com/rest/api/storageservices/blob-service-rest-api
143167
[Product documentation]: https://learn.microsoft.com/azure/storage/blobs/storage-blobs-overview
144168
[Assign an Azure role for access to blob data]: https://learn.microsoft.com/azure/storage/blobs/assign-azure-role-data-access?tabs=portal

sdk/storage/azure_storage_blob/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//
33
// Licensed under the MIT License. See License.txt in the project root for license information.
44
// Code generated by Microsoft (R) Rust Code Generator. DO NOT EDIT.
5+
6+
#![doc = include_str!("../README.md")]
57
#![allow(dead_code)]
68
#![allow(unused_imports)]
79

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Common Utilities for Azure Storage Libraries
2+
3+
This crate supports the following Azure Storage crates:
4+
5+
- [azure_storage_blob](https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/storage/azure_storage_blob)

0 commit comments

Comments
 (0)