你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
通话记录:自带 Azure 存储快速入门
使用此快速入门,可以开始使用自带 Azure 存储进行通话记录。 要开始使用自带 Azure 存储功能,请确保熟悉通话记录 API。
先决条件:设置托管标识和基于角色的访问控制 (RBAC) 角色分配
1. 为Azure 通信服务启用系统分配的托管标识
- 打开 Azure 通信服务资源。 导航到左侧的“标识”。
- 启用系统分配的托管标识,然后单击“保存”。
- 完成后,可以看到新建标识的对象主体 ID。
- 成功创建标识后,单击“Azure 角色分配”以开始添加角色分配。
2. 添加角色分配
- 单击“添加角色分配”
- 在“添加角色分配”面板上,选择以下值
- 范围:存储
- 订阅:选择自己的订阅
- 资源:选择存储帐户
- 角色:Azure 通信服务需要“存储 Blob 数据参与者”才能写入存储帐户。
- 单击“保存”。
- 完成后,可在“Azure 角色分配”窗口中看到新添加的角色分配。
使用指定的外部存储启动录制会话
使用在发起呼叫期间收到的服务器呼叫 ID。
将 Azure Blob 存储用于外部存储
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<serverCallId>"))
{
//...
ExternalStorage = new BlobStorage(new Uri("<Insert Container / Blob Uri>"))
};
Response<RecordingStateResult> startRecordingWithResponse = await callAutomationClient.GetCallRecording()
.StartRecordingAsync(options: recordingOptions);
将 Azure Blob 存储用于外部存储
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<serverCallId>"))
.setExternalStorage(new BlobStorage("<Insert Container / Blob Uri>"));
Response<StartCallRecordingResult> response = callAutomationClient.getCallRecording()
.startRecordingWithResponse(recordingOptions, null);
成功导出时的通知
使用 Azure 事件网格 Webhook 或其他触发操作,在录制的媒体准备就绪并已导出到外部存储位置时通知服务。
请参阅事件架构的此示例。
{
"id": "string", // Unique guid for event
"topic": "string", // /subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}
"subject": "string", // /recording/call/{call-id}/serverCallId/{serverCallId}
"data": {
"storageType": "string", // AzureBlob etc.
"recordingId": "string", // unique id for recording
"recordingStorageInfo": {
"recordingChunks": [
{
"documentId": "string", // Document id for the recording chunk
"contentLocation": "string", //Azure Communication Services URL where the content is located
"metadataLocation": "string", // Azure Communication Services URL where the metadata for this chunk is located
"deleteLocation": "string", // Azure Communication Services URL to use to delete all content, including recording and metadata.
"index": "int", // Index providing ordering for this chunk in the entire recording
"endReason": "string", // Reason for chunk ending: "SessionEnded", "ChunkMaximumSizeExceeded”, etc.
}
]
},
"recordingStartTime": "string", // ISO 8601 date time for the start of the recording
"recordingDurationMs": "int", // Duration of recording in milliseconds
"sessionEndReason": "string" // Reason for call ending: "CallEnded", "InitiatorLeft”, etc.
},
"eventType": "string", // "Microsoft.Communication.RecordingFileStatusUpdated"
"dataVersion": "string", // "1.0"
"metadataVersion": "string", // "1"
"eventTime": "string" // ISO 8601 date time for when the event was created
}
通话录制内容的文件夹结构
录制内容采用以下格式存储,如下图所示。
- /YYYYMMDD/callId/first_8_of_recordingId + '-' + unique guid/[chunk-id]-acsmetadata.documentId.json
- /YYYYMMDD/callId/first_8_of_recordingId + '-' + unique guid/[chunk-id]-audiomp3.documentId.mp3
后续步骤
有关详细信息,请参阅以下文章: