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 topology. /// </summary> /// <remarks> /// Creates a new topology or updates an existing one, with the given name. A /// topology is a blueprint defining what nodes are in a graph, and how they /// are interconnected. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='topology'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <MediaGraphTopology> GraphTopologySetAsync(this ILiveVideoAnalyticsEdgeClient operations, MediaGraphTopology topology, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GraphTopologySetWithHttpMessagesAsync(topology, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates or updates a graph topology. /// </summary> /// <remarks> /// Creates a new topology or updates an existing one, with the given name. A /// topology is a blueprint defining what nodes are in a graph, and how they /// are interconnected. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='topology'> /// </param> public static MediaGraphTopology GraphTopologySet(this ILiveVideoAnalyticsEdgeClient operations, MediaGraphTopology topology) { return(operations.GraphTopologySetAsync(topology).GetAwaiter().GetResult()); }