Created
October 31, 2019 02:55
-
-
Save fabriciosanchez/f9cd363e7ab00d33d8bfc24c4fe2ae3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[FunctionName("A_PublishesEncodedAsset")] | |
public static async Task<string> PublishesEncodedAsset([ActivityTrigger] string resultEncoding, TraceWriter log) | |
{ | |
// Step 1: Create the context | |
AzureAdTokenCredentials tokenCredentials = new AzureAdTokenCredentials(_tenantDomain, new AzureAdClientSymmetricKey(_clientId, _clientSecret), AzureEnvironments.AzureCloudEnvironment); | |
var tokenProvider = new AzureAdTokenProvider(tokenCredentials); | |
_context = new CloudMediaContext(new Uri(_restApiUrl), tokenProvider); | |
string streamingUrl; | |
// Step 2: Builds the streaming url for the encoded and published asset | |
try | |
{ | |
log.Info("Publishing the asset and building up the streaming url..."); | |
streamingUrl = MediaServices.PublishAndBuildStreamingURLs(resultEncoding, _context); ; | |
log.Info("Done. Asset published."); | |
log.Info($"Public URL: {streamingUrl}"); | |
} | |
catch (Exception) | |
{ | |
return string.Empty; | |
} | |
return streamingUrl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment