Communication services: how to pass an azure blog storage

Lucas Lehembre 0 Reputation points
2024-03-11T19:19:12.51+00:00

Hi there!

We are a Communication Services customer.
We have an app in Ruby on Rails and are now trying to record the sessions and get the audio file back.
I'm managing to start the call recording using the REST API described here

And received the webhook calls when the recording is ready. SO far so good.
I'm now stuck at getting the recordings back and I have two questions please:

  1. I get a contentLocation back:
    "contentLocation": "``https://fr-storage.asm.skype.com/v1/objects/0-frc-d4-e20...fccb154/content/audiomp3``"
    => How to authenticate to get the file back ?
  2. It would be even better if I could use the functionality found in this article on how to use an Azure storage account to store directly. How do I apply this to the REST API please ?
    What attributes do I put in the start_recording request body to use my Azure storage ? I have set it up just like in the article.
    I think it's lacking in the documentation of the REST APIs.

Thanks
lucas

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,718 questions
Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
688 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Nehruji R 2,126 Reputation points Microsoft Vendor
    2024-03-12T07:07:01.1633333+00:00

    Hello Lucas Lehembre,

    Greetings! Welcome to Microsoft Q&A Forum.

    I understand that you would like to know how to authenticate a file to get back and get the call recordings to the storage account directly once the recordings are ready,

    1.I get a contentLocation back: "contentLocation": "``https://fr-storage.asm.skype.com/v1/objects/0-frc-d4-e20...fccb154/content/audiomp3``" => How to authenticate to get the file back?

    When you receive a contentLocation like the one you mentioned (https://fr-storage.asm.skype.com/v1/objects/0-frc-d4-e20...fccb154/content/audiomp3), you’ll need to authenticate to access the file.

    Since you’re using the REST API, you can follow these steps:

    • Digest Authentication: Unfortunately, file_get_contents don’t directly support digest authentication. However, you can use Curl to achieve this. Here’s an example of how to do it with Curl:

    $ch = curl_init('https://fr-storage.asm.skype.com/v1/objects/0-frc-d4-e20...fccb154/content/audiomp3');

    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);

    curl_setopt($ch, CURLOPT_USERPWD, 'your_username:your_password');

    $fileContent = curl_exec($ch);

    curl_close($ch);

    // Now $fileContent contains the audio file data

    • Replace 'your_username' and 'your_password' with your actual credentials.
    • Remember that digest authentication requires additional handling compared to basic authentication.

    2.How do I apply this to the REST API please ? What attributes do I put in the start_recording request body to use my Azure storage ?

    If you’d like to store the audio files directly in an Azure storage account, you can follow these steps:

    • Set up an Azure Storage Account (if you had done already, please ignore).
    • Modify your recording process to save the audio files directly to the Azure storage account.
    • In your start_recording request body, include the necessary attributes to specify the Azure storage account details. These attributes will depend on the specifics of your implementation and the Azure SDK you’re using.
    • Configure your storage account and integrate it with your application.
    • Unfortunately, the REST API documentation doesn’t explicitly mention how to use Azure storage for recording. However, you’ll need to include the relevant information in your request body. Here’s a high-level example (you’ll need to adapt it to your specific case): {
        "recordingType": "audio",
        
        
        "storageType": "azure",
        
        
        "azureStorageSettings": {
        
        
            "accountName": "your_storage_account_name",
        
        
            "containerName": "your_container_name",
        
        
            "sasToken": "your_sas_token"
        
        
        }
      
      }
    • Replace "your_storage_account_name", "your_container_name", and "your_sas_token" with your actual Azure storage account details.
    • Ensure that your app has the necessary permissions to write to the specified container.

    refer - https://stackoverflow.com/questions/21409914/how-to-access-rest-web-service-using-file-get-contents-with-digest-authenticatio, https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/voice-video-calling/get-started-call-recording?pivots=programming-language-csharp.

    Hope this answer helps!  Please let us know if you have any further queries. I’m happy to assist you further.

    Please "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


    0 comments No comments

  2. Lucas Lehembre 0 Reputation points
    2024-03-12T11:39:48.81+00:00

    Hi Nehruji,

    I am afraid I'm still lacking information

    1. you say to replace 'your_username' and 'your_password' by mine, but what username/password are they ? To start the recording with the Communication Services, we are using an access key ?
    2. You said
      "Unfortunately, the REST API documentation doesn’t explicitly mention how to use Azure storage for recording. However, you’ll need to include the relevant information in your request body. Here’s a high-level example (you’ll need to adapt it to your specific case):
    "recordingType": "audio",
    
    "storageType": "azure",
    
    "azureStorageSettings": {
    
        "accountName": "your_storage_account_name",
    
        "containerName": "your_container_name",
    
        "sasToken": "your_sas_token"
    
    }
    

    }

    Replace "your_storage_account_name", "your_container_name", and "your_sas_token" with your actual Azure storage account details."

    => where did you get that from please ?
    => Where do I get the sasToken from ?
    => are you sure about these key names ? ("storageType": "azure" and azureStorageSettings) I was trying to understand these values from the C# SDK and they seem different from what I can see

    FYI we are trying to do a proof of concept to see if we'll strategically use Microsoft/Azure for all our needs and need to resolve this ASAP to take a decision