How to access IoTHubClient_Auth_Get_SasToken

Andre Ricardo 20 Reputation points
2024-10-09T15:37:50.4233333+00:00

We currently call IoTHubDeviceClient_LL_AzureStorageInitializeBlobUpload and pass the SAS token to an external process. We are going to upload larger files and do not want to do it in the C/ADU code, thus the external process.

if (IoTHubDeviceClient_LL_AzureStorageInitializeBlobUpload(

            device_ll_handle, path, &uploadCorrelationId, sas)

        != IOTHUB_CLIENT_OK)


The issue is that we also need to call IoTHubDeviceClient_LL_AzureStorageNotifyBlobUploadCompletion or the files/notifications endpoint or we get error 403006 "Number of active file upload requests exceeded limit"


AducIotAgent[21124]: Info: HTTP Response:{"Message":"{\"errorCode\":403006,\"message\":\"Number of active file upload requests exceeded limit\",\"trackingId\":\"395BB5681CF848498AA9C3227DE274D5-G2:-TimeStamp:2024-09-10T12:45:06.852386663Z\",\"timestampUtc\":\"2024-09-10T12:45:06.852386663Z\",\"info\":null}","ExceptionMessage":""}

We were planning to notify IoT by calling in the external process the equivalent of POST to https://our_iot_hub.azure-devices.net/devices/my-device/files/notifications


curl --request POST \

  --url 'https://our_iot_hub.azure-devices.net/devices/my-device/files/notifications?api-version=2021-04-12' \

  --header 'Authorization: SharedAccessSignature sr=our_iot_hub.azure-devices.net&sig=[REDACTED]&se=1726066175&skn=iothubowner' \

  --header 'content-type: application/json' \

  --data '{

        "correlationId": "MjA....",

        "isSuccess": true,

        "statusCode": 200,

        "statusDescription": "File uploaded successfully"

  }'

In order to get this signature we would like to call the equivalent from the Azure IoT C SDK IoTHubClient_Auth_Get_SasToken

https://github.com/Azure/azure-iot-sdk-c/blob/b8af2f4ee2b909e5c6a72b8f95bda4ba62e2052d/iothub_client/src/iothub_client_ll_uploadtoblob.c#L348-L349

Any way we can do this?

Azure IoT SDK
Azure IoT SDK
An Azure software development kit that facilitates building applications that connect to Azure IoT services.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Amira Bedhiafi 39,341 Reputation points Volunteer Moderator
    2025-09-11T16:21:15.0633333+00:00

    Hello Andre !

    Thank you for posting on Microsoft Q&A.

    I don't think you will be able to do that since IoTHubClient_Auth_Get_SasToken is an internal helper and isn’t exposed by the C SDK so there’s no supported way to pull the SDK current SAS token out of IoTHubDeviceClient* for your own REST calls.

    https://azure.github.io/azure-iot-sdk-c/iothub__device__client__ll_8h.html

    Try to call IoTHubDeviceClient_LL_AzureStorageInitializeBlobUpload(...) and pass only azureBlobSasUri to your external uploader and when the uploader returns, call IoTHubDeviceClient_LL_AzureStorageNotifyBlobUploadCompletion(...) with the original correlationId and success/failure. This way you won't be exposing device keys outside your agent and exactly follows the SDK contract.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.