This application upload HLS streaming contents to Azure Blob Storage using Azure Functions and request CDN pre-loading using Azure CDN REST API.
- Request upload item to /api/upload API (RequestUploadFunction)
- Parse HLS URL to recognize all the files need to copy and insert Azure Queue with 10 items (M3u8UrlParseFunction)
- ContentUploaderFunction tirgger by Queue and upload 10 items to Azure blob storage (ContentUploaderFunction)
- Monitor the progress using /api/monitor and /api/status API (MonitorUploadFunction, UploadStatusFunction)
Code runs on Azure App Services.
- Request URL: http://{app-service-name}.azurewebsites.net/api/upload?code={secretcode}}
- Method: POST
- Header
- Content-Type: application/json
- Body
- primaryUrl : Main playlist URL
- secondaryUrls: Secondary playlist URL
- Request
{
"primaryUrl": "https://{hostname}/playlist_1080.m3u8",
"secondaryUrls" : [
"https://{hostname}/playlist_720.m3u8",
"https://{hostname}/playlist_480.m3u8",
"https://{hostname}/playlist_360.m3u8",
"https://{hostname}/playlist_300.m3u8"
]
}
- Response: Success (200)
{
"status": "success",
"data": "",
"message": "requested: http://{hostname}/playlist_1080.m3u8"
}
- Response: Failed (500)
{
"status": "error",
"data": "{request body}",
"message": "{error message}"
}
- Request URL: http://{app-service-name}.azurewebsites.net/api/status?code={secret-code}
- Method: POST
- Body: primaryUrl by string (not json)
- Response 성공(200)
{
"url": " http://{hostname}/playlist_1080.m3u8",
"fileCount": 3271,
"completeCount": 866,
"progress": 0.2647508407214918985019871599,
"hasError": false
}
fileCount | Total file count |
completeCount | Complete Count |
progress | (fileCount / complete) |
- Request URL: http://{app-service-name}.azurewebsites.net/api/monitor?code={secretcode}
- Method: GET
- Response: Success(200)
{
"totalCount": 9,
"errorCount": 1,
"ongoingCount": 3,
"ongoingList": [
{
"url": "http://odkcdn1.azureedge.net/72sec/playlist_1080.m3u8",
"fileCount": 3457,
"completeCount": 902,
"progress": 0.2609198727220133063349725195,
"hasError": false
},
{
"url": "http://odkcdn1.azureedge.net/infinite-challenge/infinite-challenge-e528/playlist_720.m3u8",
"fileCount": 3271,
"completeCount": 891,
"progress": 0.2723937633751146438398043412,
"hasError": false
},
{
"url": "http://odkcdn1.azureedge.net/youns-kitchen/youns-kitchen-e7/playlist_720.m3u8",
"fileCount": 3589,
"completeCount": 1521,
"progress": 0.4237949289495681248258567846,
"hasError": true
}
],
"errorList": [
{
"url": "http://odkcdn1.azureedge.net/youns-kitchen/youns-kitchen-e7/playlist_720.m3u8",
"fileCount": 3589,
"completeCount": 1521,
"progress": 0.4237949289495681248258567846,
"hasError": true
}
]
}
totalCount | Total Content count |
errorCount | Content count that has error |
ongoingCount | Content count that is uploading |
ongoingList | Detail list of uploading content |
errorList | Detail List of error content |
Azure CDN can be set the origin using Azure blob storage. But uploaded contents won't cache on CDN immediately. One or more requests of the content need to cache them. Pre-load request is very useful to improve CDN performance. Azure CDN pre-load feature has limit, 10 urls per minute, and it will take 2-3 minutes to finish pre-load. So the code request only 100 seconds of the content.