Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fabriciosanchez
Created October 29, 2019 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabriciosanchez/296823ba0345effba60a8ea4e28a2349 to your computer and use it in GitHub Desktop.
Save fabriciosanchez/296823ba0345effba60a8ea4e28a2349 to your computer and use it in GitHub Desktop.
[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;
string _storageAccountName = videoModel.StorageAccountName;
string _videoPath = videoModel.VideoPath;
string _videoFileName = videoModel.VideoFileName;
// Is it valid?
if (string.IsNullOrEmpty(_accessPolicy) || string.IsNullOrEmpty(_assetName) || string.IsNullOrEmpty(_storageAccountName) || string.IsNullOrEmpty(_videoPath) || string.IsNullOrEmpty(_videoFileName))
{
return req.CreateResponse(HttpStatusCode.BadRequest, "Invalid input data. Expected: Access Policy, Asset Name, StorageAccount Name, Video Path, Video Name.");
}
log.Info($"All set! Starting the orchestration process for {_videoFileName}...");
// Starting the orchestration process
var orchestrationId = await starter.StartNewAsync("O_Orchestrator", videoModel);
// Checking orchestration status
return starter.CreateCheckStatusResponse(req, orchestrationId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment