public async Task SendPipelineRequests()
        {
            try
            {
                // create a pipeline topology and live pipeline
                var pipelineTopology = BuildPipelineTopology();
                var livePipeline     = BuildLivePipeline(pipelineTopology.Name);

                //set topology without using helper function
                #region Snippet:Azure_VideoAnalyzerSamples_InvokeDirectMethod
                var setPipelineTopRequest = new PipelineTopologySetRequest(pipelineTopology);

                var directMethod = new CloudToDeviceMethod(setPipelineTopRequest.MethodName);
                directMethod.SetPayloadJson(setPipelineTopRequest.GetPayloadAsJson());

                var setPipelineTopResponse = await serviceClient.InvokeDeviceMethodAsync(deviceId, moduleId, directMethod);

                #endregion Snippet:Azure_VideoAnalyzerSamples_InvokeDirectMethod

                // get a topology using helper function
                var getPipelineTopRequest = await InvokeDirectMethodHelper(new PipelineTopologyGetRequest(pipelineTopology.Name));

                var getPipelineTopResponse = PipelineTopology.Deserialize(getPipelineTopRequest.GetPayloadAsJson());

                // list all  topologies
                var listPipelineTopRequest = await InvokeDirectMethodHelper(new PipelineTopologyListRequest());

                var listPipelineTopResponse = PipelineTopologyCollection.Deserialize(listPipelineTopRequest.GetPayloadAsJson());

                //set live pipeline
                var setLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineSetRequest(livePipeline));

                //activate live pipeline
                var activateLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineActivateRequest(livePipeline.Name));

                //get live pipeline
                var getLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineGetRequest(livePipeline.Name));

                var getLivePipelineResponse = LivePipeline.Deserialize(getLivePipelineRequest.GetPayloadAsJson());

                // list all live pipeline
                var listLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineListRequest());

                var listLivePipelineResponse = LivePipelineCollection.Deserialize(listLivePipelineRequest.GetPayloadAsJson());

                //getlive pipeline
                var deactiveLivePipeline = await InvokeDirectMethodHelper(new LivePipelineDeactivateRequest(livePipeline.Name));

                var deleteLivePipeline = await InvokeDirectMethodHelper(new LivePipelineDeleteRequest(livePipeline.Name));

                //delete live pipeline
                var deletePipelineTopology = await InvokeDirectMethodHelper(new PipelineTopologyDeleteRequest(pipelineTopology.Name));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Assert.Fail();
            }
        }
        public async Task SendRequests()
        {
            try
            {
                //create a pipeline topology and live pipeline
                var pipelineTopology = BuildPipelineTopology();
                var livePipeline     = BuildLivePipeline(pipelineTopology.Name);

                //set topology without using helper function
                #region Snippet:Azure_VideoAnalyzerSamples_InvokeDirectMethod
                var setPipelineTopRequest = new PipelineTopologySetRequest(pipelineTopology);

                var directMethod = new CloudToDeviceMethod(setPipelineTopRequest.MethodName);
                directMethod.SetPayloadJson(setPipelineTopRequest.GetPayloadAsJson());

                var setPipelineTopResponse = await _serviceClient.InvokeDeviceMethodAsync(_deviceId, _moduleId, directMethod);

                #endregion Snippet:Azure_VideoAnalyzerSamples_InvokeDirectMethod

                // get a topology using helper function
                var getPipelineTopRequest = await InvokeDirectMethodHelper(new PipelineTopologyGetRequest(pipelineTopology.Name));

                var getPipelineTopResponse = PipelineTopology.Deserialize(getPipelineTopRequest.GetPayloadAsJson());

                // list all  topologies
                var listPipelineTopRequest = await InvokeDirectMethodHelper(new PipelineTopologyListRequest());

                var listPipelineTopResponse = PipelineTopologyCollection.Deserialize(listPipelineTopRequest.GetPayloadAsJson());

                //set live pipeline
                var setLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineSetRequest(livePipeline));

                //activate live pipeline
                var activateLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineActivateRequest(livePipeline.Name));

                //get live pipeline
                var getLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineGetRequest(livePipeline.Name));

                var getLivePipelineResponse = LivePipeline.Deserialize(getLivePipelineRequest.GetPayloadAsJson());

                // list all live pipeline
                var listLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineListRequest());

                var listLivePipelineResponse = LivePipelineCollection.Deserialize(listLivePipelineRequest.GetPayloadAsJson());

                //getlive pipeline
                var deactiveLivePipeline = await InvokeDirectMethodHelper(new LivePipelineDeactivateRequest(livePipeline.Name));

                var deleteLivePipeline = await InvokeDirectMethodHelper(new LivePipelineDeleteRequest(livePipeline.Name));

                //delete live pipeline
                var deletePipelineTopology = await InvokeDirectMethodHelper(new PipelineTopologyDeleteRequest(pipelineTopology.Name));

                //get an onvif device
                var onvifDeviceGetRequest = await InvokeDirectMethodHelper(new OnvifDeviceGetRequest(new UnsecuredEndpoint("rtsp://camerasimulator:8554")));

                var onvifDeviceGetResponse = OnvifDevice.Deserialize(onvifDeviceGetRequest.GetPayloadAsJson());

                //get all onvif devices on the network
                var onvifDiscoverRequest = await InvokeDirectMethodHelper(new OnvifDeviceDiscoverRequest());

                var onvifDiscoverResponse = DiscoveredOnvifDeviceCollection.Deserialize(onvifDiscoverRequest.GetPayloadAsJson());

                // create a remote device adapter and send a set request for it
                var iotDeviceName    = "iotDeviceSample";
                var remoteDeviceName = "remoteDeviceSample";
                var iotDevice        = await GetOrAddIoTDeviceAsync(iotDeviceName);

                var remoteDeviceAdapter           = CreateRemoteDeviceAdapter(remoteDeviceName, iotDeviceName, iotDevice.Authentication.SymmetricKey.PrimaryKey);
                var remoteDeviceAdapterSetRequest = await InvokeDirectMethodHelper(new RemoteDeviceAdapterSetRequest(remoteDeviceAdapter));

                var remoteDeviceAdapterSetResponse = RemoteDeviceAdapter.Deserialize(remoteDeviceAdapterSetRequest.GetPayloadAsJson());

                //get a remote device adapter
                var remoteDeviceAdapterGetRequest = await InvokeDirectMethodHelper(new RemoteDeviceAdapterGetRequest(remoteDeviceName));

                var remoteDeviceAdapterGetResponse = RemoteDeviceAdapter.Deserialize(remoteDeviceAdapterGetRequest.GetPayloadAsJson());

                //list all remote device adapters
                var remoteDeviceAdapterListRequest = await InvokeDirectMethodHelper(new RemoteDeviceAdapterListRequest());

                var remoteDeviceAdapterListResponse = RemoteDeviceAdapterCollection.Deserialize(remoteDeviceAdapterListRequest.GetPayloadAsJson());

                //delete a remote device adapater
                var remoteDeviceAdapterDeleteRequest = await InvokeDirectMethodHelper(new RemoteDeviceAdapterDeleteRequest(remoteDeviceName));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Assert.Fail();
            }
        }