Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access IoTHubClient_Auth_Get_SasToken #2653

Open
AndreRicardo-Zoetis opened this issue Oct 9, 2024 · 0 comments
Open

How to access IoTHubClient_Auth_Get_SasToken #2653

AndreRicardo-Zoetis opened this issue Oct 9, 2024 · 0 comments
Labels

Comments

@AndreRicardo-Zoetis
Copy link

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

uint64_t expiry = (uint64_t)(difftime(curr_time, 0) + 3600);
char* sas_token = IoTHubClient_Auth_Get_SasToken(upload_data->authorization_module, STRING_c_str(uri_resource), expiry, EMPTY_STRING);

Any way we can do this?

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

No branches or pull requests

1 participant