Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Accessing Azure storage Queue #319

Closed
Herlix opened this issue Sep 24, 2020 · 6 comments · Fixed by #320
Closed

Accessing Azure storage Queue #319

Herlix opened this issue Sep 24, 2020 · 6 comments · Fixed by #320

Comments

@Herlix
Copy link

Herlix commented Sep 24, 2020

Hi!

Not sure if this is the correct place for this question.

Is there a way to use this SDK to access Azure storage queue?

I'm having trouble generating a valid token/request and keep getting 403.

Here's my qurestion on stackoverflow: https://stackoverflow.com/questions/64053017/calling-azure-storare-queue-rest-api-using-rust

I've looked at the rest_client in this project, though it seems you guys have not yet implemented Queue storage capability yet? =)

Thanks!

@MindFlavor
Copy link
Owner

Hi @Herlix, unfortunately there is no support for Azure storage queue at the moment, but the scaffolding is in place so it should be easy to add.
In Microsoft we are restructuring this repository so this could take a little while but now that I know someone is interested in using queue storage I will definitely add it!

@MindFlavor
Copy link
Owner

While not aiming to be feature-complete, the aforementioned PR should give you what you need!

For example, to put a message you can refer to: azure_sdk_storage_queue/examples/put_message.rs.
It goes like this:

// Create an Azure storage client (with master key auth) and specialize it into a
// queue service client instance.
let client = client::with_access_key(&account, &master_key).into_queue_service_client();

// Specialize the queue client into a specific queue client.
// Then call the put_message function.
// Make sure to pass the body or the function won't compile!
let response = client
        .with_queue_name_client("queuename")
        .put_message()
        .with_message_body("Azure SDK for Rust rocks!")
        .execute()
        .await?;

Please let me know what you think!

@Herlix
Copy link
Author

Herlix commented Sep 29, 2020

While not aiming to be feature-complete, the aforementioned PR should give you what you need!

For example, to put a message you can refer to: azure_sdk_storage_queue/examples/put_message.rs.
It goes like this:

// Create an Azure storage client (with master key auth) and specialize it into a
// queue service client instance.
let client = client::with_access_key(&account, &master_key).into_queue_service_client();

// Specialize the queue client into a specific queue client.
// Then call the put_message function.
// Make sure to pass the body or the function won't compile!
let response = client
        .with_queue_name_client("queuename")
        .put_message()
        .with_message_body("Azure SDK for Rust rocks!")
        .execute()
        .await?;

Please let me know what you think!

I will try it. It looks good form the look of what you showed!
Awsome!

@Herlix
Copy link
Author

Herlix commented Sep 29, 2020

It looks good!

I've tried it out and had a quick look at the code.

A minor thing, but it might be a good idea to document the wrapping of the message that is sent :)

/// Wraps the message like: '\<QueueMessage>\<MessageText>{}\</MessageText>\</QueueMessage>'
pub trait MessageBodySupport<'b> {
    type O;
    /// Wraps the content with a '\<QueueMessage>\<MessageText>{}\</MessageText>\</QueueMessage>'
    fn with_message_body<BODY: Into<Cow<'b, str>>>(self, body: BODY) -> Self::O;
}
let message = format!(
     "<QueueMessage><MessageText>{}</MessageText></QueueMessage>",
     self.message_body()
);

I'm really happy for this, I generated the token myself and got it working. But relying on a separate crate for this feels better. This API is very nice and clean too from the users perspective.

I like the builder patterns and how easy it is to use. Thank you!

@MindFlavor
Copy link
Owner

Thank you for your feedback! ❤️

As for the wrapping, you are right, it should be documented: it's a requirement of the REST API specification (https://docs.microsoft.com/en-us/rest/api/storageservices/put-message) but it's not clear beforehand!

@MindFlavor
Copy link
Owner

I've stripped many functions from the PR in order to speed up the migration towards the Microsoft Azure org. I hope to complete the migration ASAP and return to work on this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants