Skip to content

Instantly share code, notes, and snippets.

View fabriciosanchez's full-sized avatar

Fabrício Sanchez fabriciosanchez

View GitHub Profile
@fabriciosanchez
fabriciosanchez / vnet-configuration.ps1
Created April 10, 2020 17:38
Retrieving existing VNet info and adding two new subnets into it.
# Retriving vnet information
$vnet = Get-AzVirtualNetwork -Name vnet-americasuniversity -ResourceGroupName CoreResources
# Adding appgtw-subnet to the existing VNet
$subnetAGConfig = Add-AzVirtualNetworkSubnetConfig `
-Name appgtw-subnet `
-AddressPrefix 10.1.5.0/28 `
-VirtualNetwork $vnet
# Adding apim-subnet to the existing VNet
@fabriciosanchez
fabriciosanchez / create-new-resource-group.ps1
Created April 10, 2020 17:35
Creates a new resource group: AUManager_Shared_Resources
$resGroupName = "AUManager_Shared_Resources"
$location = "eastus" # select your prefered region
New-AzResourceGroup -Name $resGroupName -Location $location
private async Task<ActionResult> RunQueryVideoAsync(SearchDataVideo model)
{
// Retrieving the access token from the service
string accessToken = await GetVideoIndexerAccessToken();
// Setting up HTTP client request
HttpClient _httpClientSearchVideos = new HttpClient();
// Pulling off video indexer API information
_builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");
private async Task<ActionResult> RunQueryAsync(SearchData model)
{
InitSearch();
var parameters = new SearchParameters
{
// Enter content property names into this list so only these values will be returned.
// If Select is empty, all values will be returned, which can be inefficient.
Select = new[] { "Column1", "Column2", "ColumnN" }
};
[FunctionName("A_InsightsGenerator")]
public static string GeneratesInsights([ActivityTrigger] AMSVideo amsVideoPublished, TraceWriter log)
{
// Building up Json sentence
dynamic flexibleObj = new ExpandoObject();
flexibleObj.assetId = amsVideoPublished.Asset.Id;
flexibleObj.videoFileName = amsVideoPublished.Video.VideoFileName;
flexibleObj.streamingVideoURL = amsVideoPublished.StreamingURL;
var jsonStr = JsonConvert.SerializeObject(flexibleObj);
[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
[FunctionName("A_JobEncodingGenerator")]
public static string GeneratesEncoder([ActivityTrigger] InitialSetupResult initialSetupResult, TraceWriter log)
{
IJob job;
// Step 1: Setting up queue, context and endpoint
string endPointAddress = Guid.NewGuid().ToString();
AzureAdTokenCredentials tokenCredentials = new AzureAdTokenCredentials(_tenantDomain, new AzureAdClientSymmetricKey(_clientId, _clientSecret), AzureEnvironments.AzureCloudEnvironment);
var tokenProvider = new AzureAdTokenProvider(tokenCredentials);
public static class A_InitialSetupGenerator
{
// AD auth variables
static readonly string _tenantDomain = Environment.GetEnvironmentVariable("AMSAADTenantDomain");
static readonly string _restApiUrl = Environment.GetEnvironmentVariable("AMSRESTAPIEndpoint");
static readonly string _clientId = Environment.GetEnvironmentVariable("AMSClientId");
static readonly string _clientSecret = Environment.GetEnvironmentVariable("AMSClientSecret");
static readonly string _storageConnection = Environment.GetEnvironmentVariable("StorageAccountConnection");
[FunctionName("A_InitialSetupGenerator")]
[FunctionName("O_Orchestrator")]
public static async Task<object> OrchestratesVideoProcessing([OrchestrationTrigger] DurableOrchestrationContext context, TraceWriter log)
{
HttpResponseMessage httpResponse = new HttpResponseMessage();
// Holding the video location through the context
var videoDto = context.GetInput<VideoAMS>();
InitialSetupResult resultInitialSetup;
AMSVideo amsVideoPublished;
string resultEncoding, resultPublishing, resultInsights;
[FunctionName("Starter")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, [OrchestrationClient] DurableOrchestrationClient starter, TraceWriter log)
{
// Reading call's body and typing it
string json = await req.Content.ReadAsStringAsync();
var videoModel = JsonConvert.DeserializeObject<VideoAMS>(json);
// Sets up the content
string _accessPolicy = videoModel.AccessPolicyName;
string _assetName = videoModel.AssetName;