How to tell how many blob storage sas tokens have been requested for a device?

bcb44 86 Reputation points
2021-04-20T03:41:22.687+00:00

I'm using the File Upload operation in IoT Hub to send aggregated telemetry from our devices to blob storage. Our devices sometimes lose power and aren't able to invoke a cancelation token or send a 400 error code to IoT Hub before shutting down. Then they start back up and don't know how many of the 10 upload tokens are available.

Is there a property I can poll to see how many tokens are active at a certain time for a device?

Thanks

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,115 questions
Azure IoT SDK
Azure IoT SDK
An Azure software development kit that facilitates building applications that connect to Azure IoT services.
208 questions
0 comments No comments
{count} vote

Accepted answer
  1. QuantumCache 20,031 Reputation points
    2021-06-03T14:26:56.007+00:00

    Hello @bcb44 Thanks for posting this great question which is very useful to other community members as well.

    Question:There's not a IoT Hub property I can query to check the number of SAS URI's are in use by my device?
    Response: Unfortunately, not available!

    Below is the response from the Microsoft Product team addressing your initial query and along with a workaround.

    There is a rate limit of 100/min/unit for file uploads as of now, Reference - IoT Hub quotas and throttling.

    The alternative is to use a blob client on the device and connect directly to the Blob service bypassing the limit, it will also allow more flexibility. Associated key or token can be passed to the device via twin or direct method, so configurable.

    Also, I hope you have already referred to : Azure Storage samples using v12 .NET client libraries

    Your workaround is also more thoughtful > "I would write to a file to keep track... "

    Please comment in the below section for further feedbacks or help in this matter.

    If the response is helpful, please click "Accept Answer" and upvote it.


1 additional answer

Sort by: Most helpful
  1. António Sérgio Azevedo 7,661 Reputation points Microsoft Employee
    2021-04-20T11:19:51.083+00:00

    Hi @bcb44 ,
    The SAS URIs returned to the device by IoT Hub contain the information you need.

    See here: https://learn.microsoft.com/en-us/rest/api/storageservices/create-service-sas

    89536-image.png

    "The access policy portion of the URI indicates the period of time over which the shared access signature is valid and the permissions to be granted to the user."

    Ones you are interested:

    89537-image.png

    See also how to Configure IoT Hub file uploads using Azure CLI .

    • "SAS TTL: This setting is the time-to-live of the SAS URIs returned to the device by IoT Hub. Set to one hour by default."

    Hope I could help!

    Remember:

    • Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification.