public async Task SendGraphRequests() { try { // create a graph topology and graph instance var graphTopology = BuildGraphTopology(); var graphInstance = BuildGraphInstance(graphTopology.Name); //set graph topology without using helper function #region Snippet:Azure_MediaServices_Samples_InvokeDirectMethod var setGraphRequest = new MediaGraphTopologySetRequest(graphTopology); var directMethod = new CloudToDeviceMethod(setGraphRequest.MethodName); directMethod.SetPayloadJson(setGraphRequest.GetPayloadAsJson()); var setGraphResponse = await _serviceClient.InvokeDeviceMethodAsync(_deviceId, _moduleId, directMethod); #endregion Snippet:Azure_MediaServices_Samples_InvokeDirectMethod // get a graph topology using helper function var getGraphResponse = await InvokeDirectMethodHelper(new MediaGraphTopologyGetRequest(graphTopology.Name)); var getGraphResult = MediaGraphTopology.Deserialize(getGraphResponse.GetPayloadAsJson()); // list all graph topologies var listGraphResponse = await InvokeDirectMethodHelper(new MediaGraphTopologyListRequest()); var listGraphResult = MediaGraphTopologyCollection.Deserialize(listGraphResponse.GetPayloadAsJson()); //set graph instance var setGraphInstanceResult = await InvokeDirectMethodHelper(new MediaGraphInstanceSetRequest(graphInstance)); //activate graph instance var activateGraphResponse = await InvokeDirectMethodHelper(new MediaGraphInstanceActivateRequest(graphInstance.Name)); //get instance var getGraphInstanceResponse = await InvokeDirectMethodHelper(new MediaGraphInstanceGetRequest(graphInstance.Name)); var getGraphInstanceResult = MediaGraphInstance.Deserialize(getGraphInstanceResponse.GetPayloadAsJson()); // list all graph instance var listGraphInstanceResponse = await InvokeDirectMethodHelper(new MediaGraphInstanceListRequest()); var listGraphInstanceResult = MediaGraphInstanceCollection.Deserialize(listGraphInstanceResponse.GetPayloadAsJson()); //get deactive graph var deactiveGraphInstance = await InvokeDirectMethodHelper(new MediaGraphInstanceDeActivateRequest(graphInstance.Name)); //delete graph var deleteGraphTopology = await InvokeDirectMethodHelper(new MediaGraphTopologyDeleteRequest(graphTopology.Name)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
/// <summary> /// Creates or updates a graph instance. /// </summary> /// <remarks> /// Creates or updates a graph instance. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='instance'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <MediaGraphInstance> GraphInstanceSetAsync(this ILiveVideoAnalyticsEdgeClient operations, MediaGraphInstance instance, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GraphInstanceSetWithHttpMessagesAsync(instance, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates or updates a graph instance. /// </summary> /// <remarks> /// Creates or updates a graph instance. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='instance'> /// </param> public static MediaGraphInstance GraphInstanceSet(this ILiveVideoAnalyticsEdgeClient operations, MediaGraphInstance instance) { return(operations.GraphInstanceSetAsync(instance).GetAwaiter().GetResult()); }