Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ members = [
"sdk/storage/azure_storage_common",
"sdk/storage/azure_storage_blob",
"sdk/storage/azure_storage_queue",
"sdk/avs/azure_resourcemanager_vmware",
]
exclude = [
"eng/scripts/",
Expand Down
14 changes: 14 additions & 0 deletions sdk/avs/azure_resourcemanager_vmware/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Release History

## 0.1.0 (Unreleased)

### Features Added

- Initial preview release of the `azure_resourcemanager_vmware` crate
- Support for managing Azure VMware Solution (Microsoft.AVS) resources

### Breaking Changes

### Bugs Fixed

### Other Changes
31 changes: 31 additions & 0 deletions sdk/avs/azure_resourcemanager_vmware/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "azure_resourcemanager_vmware"
version = "0.1.0"
description = "Rust client library for Azure VMware Solution (Microsoft.AVS)"
readme = "README.md"
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
homepage = "https://github.com/azure/azure-sdk-for-rust"
documentation = "https://docs.rs/azure_resourcemanager_vmware"
keywords = ["sdk", "azure", "cloud", "vmware", "avs"]
categories = ["api-bindings"]

[features]
default = ["azure_core/default"]

[dependencies]
async-trait = { workspace = true }
azure_core = { workspace = true }
serde = { workspace = true }

[dev-dependencies]
azure_core_test = { workspace = true, features = ["tracing"] }
azure_identity.workspace = true
futures.workspace = true
tokio.workspace = true

[lints]
workspace = true
130 changes: 130 additions & 0 deletions sdk/avs/azure_resourcemanager_vmware/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Azure VMware Solution client library for Rust

Azure VMware Solution (AVS) is a Microsoft service that runs VMware workloads
natively on Azure infrastructure. The `azure_resourcemanager_vmware` crate
provides Rust bindings for managing AVS private clouds, clusters, datastores,
and related resources through the Microsoft.AVS resource provider.

- [Package (crates.io)](https://crates.io/crates/azure_resourcemanager_vmware)
- [API reference documentation](https://docs.rs/azure_resourcemanager_vmware)
- [Product documentation](https://learn.microsoft.com/azure/azure-vmware/)
- [Source code](https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/avs/azure_resourcemanager_vmware)

## Getting started

### Install the package

Add the crate to your `Cargo.toml`:

```toml
[dependencies]
azure_resourcemanager_vmware = "0.1.0"
azure_identity = "0.30.0"
```

### Prerequisites

- An [Azure subscription](https://azure.microsoft.com/free/)
- An Azure VMware Solution private cloud, or permissions to create one

### Authenticate the client

The client uses Entra ID (Azure Active Directory) authentication. During
development you can use `DeveloperToolsCredential`, which chains the Azure
CLI, Azure PowerShell, and other developer credentials:

```rust no_run
use azure_identity::DeveloperToolsCredential;
use azure_resourcemanager_vmware::{AVSClient, AVSClientOptions};
use std::sync::Arc;

let credential = Arc::new(DeveloperToolsCredential::new(None)?);
let client = AVSClient::new(
"https://management.azure.com",
credential,
"<subscription-id>".to_string(),
None,
)?;
```

## Key concepts

### AVSClient

The [`AVSClient`] is the primary entry point. It provides access to
sub-clients for each resource type (private clouds, clusters, hosts,
datastores, and more).

## Examples

### List private clouds

```rust no_run
use azure_identity::DeveloperToolsCredential;
use azure_resourcemanager_vmware::{AVSClient, AVSClientOptions};
use std::sync::Arc;

#[tokio::main]
async fn main() -> azure_core::Result<()> {
let credential = Arc::new(DeveloperToolsCredential::new(None)?);
let client = AVSClient::new(
"https://management.azure.com",
credential,
"<subscription-id>".to_string(),
None,
)?;

let private_clouds_client = client.private_clouds_client();
let mut pager = private_clouds_client
.list_in_subscription()
.send()
.await?
.into_body()
.await?;

// Process the results
for cloud in &pager.value {
println!("{:?}", cloud);
}

Ok(())
}
```

## Troubleshooting

### General

Azure VMware Solution clients raise errors from `azure_core::Error`. For
example, attempting to access a resource that does not exist returns a 404:

```rust no_run
use azure_core::error::ErrorKind;

match result {
Err(e) if matches!(e.kind(), ErrorKind::HttpResponse { status, .. } if *status == 404) => {
println!("Resource not found");
}
Err(e) => return Err(e.into()),
Ok(response) => { /* use response */ }
}
```

## Contributing

This project welcomes contributions and suggestions. Most contributions require
you to agree to a Contributor License Agreement (CLA) declaring that you have
the right to, and actually do, grant us the rights to use your contribution.
For details, visit <https://cla.microsoft.com>.

When you submit a pull request, a CLA-bot will automatically determine whether
you need to provide a CLA and decorate the PR appropriately (e.g., label,
comment). Simply follow the instructions provided by the bot. You will only need
to do this once across all repos using our CLA.

This project has adopted the
[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information, see the
[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any
additional questions or comments.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

use azure_identity::DeveloperToolsCredential;
use azure_resourcemanager_vmware::AVSClient;
use futures::TryStreamExt;
use std::env;

/// Lists all Azure VMware Solution private clouds in the current subscription.
///
/// # Usage
///
/// ```sh
/// # Set subscription ID via env var or pass as an argument
/// export AZURE_SUBSCRIPTION_ID="00000000-0000-0000-0000-000000000000"
/// cargo run -p azure_resourcemanager_vmware --example list_private_clouds
/// ```
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let subscription_id = env::args()
.nth(1)
.or_else(|| env::var("AZURE_SUBSCRIPTION_ID").ok())
.expect("AZURE_SUBSCRIPTION_ID must be set or passed as an argument");

let credential = DeveloperToolsCredential::new(None)?;
let client = AVSClient::new(
"https://management.azure.com",
credential,
subscription_id,
None,
)?;

let private_clouds_client = client.get_avs_private_clouds_client();
let mut pager = private_clouds_client.list_in_subscription(None)?;

println!("{:<40} {:<15} {}", "NAME", "LOCATION", "ID");
println!("{}", "-".repeat(100));

while let Some(cloud) = pager.try_next().await? {
println!(
"{:<40} {:<15} {}",
cloud.name.as_deref().unwrap_or("-"),
cloud.location.as_deref().unwrap_or("-"),
cloud.id.as_deref().unwrap_or("-"),
);
}

Ok(())
}
Loading
Loading