forked from Azure/azure-sdk-for-rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from minghuaw/eventhubs_over_amqp
Changing DEFAULT_SCOPE to DEFAULT_RESOURCE
- Loading branch information
Showing
9 changed files
with
134 additions
and
137 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
sdk/messaging_eventhubs/examples/producer_with_azure_identity_credential.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use azeventhubs::producer::{ | ||
EventHubProducerClient, EventHubProducerClientOptions, SendEventOptions, | ||
}; | ||
use azure_identity::DefaultAzureCredential; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let namespace = std::env::var("EVENT_HUBS_NAMESPACE")?; | ||
let fqn = format!("{}.servicebus.windows.net", namespace); | ||
let event_hub_name = std::env::var("EVENT_HUB_NAME")?; | ||
let options = EventHubProducerClientOptions::default(); | ||
let default_credential = DefaultAzureCredential::default(); | ||
|
||
let mut producer_client = EventHubProducerClient::from_namespace_and_credential( | ||
fqn, | ||
event_hub_name, | ||
default_credential, | ||
options, | ||
) | ||
.await?; | ||
|
||
let event = "test connect using azure identity"; | ||
let options = SendEventOptions::new().with_partition_id("0"); | ||
producer_client.send_event(event, options).await?; | ||
|
||
producer_client.close().await?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.