Open huskercane opened 4 months ago
I think I have to network_interfaces instead of network_interface_configurations
Here is the updated example
/*
prints information about network addresses used for each Azure Service
$ cargo run --release --example list_network_configuration <resource_group> <vm_name>
$
*/
use azure_identity::AzureCliCredential;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resource_group_name = std::env::args().nth(1).expect("please specify resource group name");
let vm_name = std::env::args().nth(2).expect("please specify vm group name");
let credential = Arc::new(AzureCliCredential::new());
let subscription_id = AzureCliCredential::get_subscription().await?;
let compute_client = azure_mgmt_compute::Client::builder(credential.clone()).build()?;
// Get the VM
let vm = compute_client.virtual_machines_client().get(resource_group_name, vm_name, subscription_id).await?;
let interface_name = vm.properties.unwrap().network_profile.unwrap().network_interfaces[0].clone().id.unwrap();
let last_part = interface_name.split('/').last().unwrap_or("");
println!("Interface Name is: {}", last_part);
Ok(())
}
id property does not exist for NetworkInterfaceReference
so we need this patch
Index: services/mgmt/compute/src/package_2023_10_02/models.rs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/services/mgmt/compute/src/package_2023_10_02/models.rs b/services/mgmt/compute/src/package_2023_10_02/models.rs
--- a/services/mgmt/compute/src/package_2023_10_02/models.rs (revision 8c4caa251c3903d5eae848b41bb1d02a4d65231c)
+++ b/services/mgmt/compute/src/package_2023_10_02/models.rs (date 1719279566813)
@@ -7095,6 +7095,9 @@
#[doc = "Describes a network interface reference."]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default)]
pub struct NetworkInterfaceReference {
+ #[doc = "Resource Id."]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub id: Option<String>,
#[serde(flatten)]
pub sub_resource: SubResource,
#[doc = "Describes a network interface reference properties."]
Hello
following code does not work
it fails because network_interface_configurations returns a empty vector
Equivalent code does work on Python SDK
Thank You