Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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