简体   繁体   中英

Azure IOT EDGE Get resource properties from EGDE using c#

I need to get resource from AZURE IOT EDGE using c#, here is the link where I need to list all properties for this entity. https//docs.microsoft.com/en-us/cli/azure/ext/azure-iot/iot/edge/deployment?view=azure-cli-latest#ext_azure_iot_az_iot_edge_deployment_list

You can use C# code to exec azure cli command.

My test code is too simple, you can search ProcessAsyncHelper in github, then use to your project.

In cmd tools.

在此处输入图像描述

By C# code, you need to az login first.

在此处输入图像描述

Sample Code

 static void Main(string[] args)
    {
        ProcessStartInfo startinfo = new ProcessStartInfo();
        startinfo.FileName = @"cmd.exe";
        Process process = new Process();
        process.StartInfo = startinfo;
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.RedirectStandardInput = true;
        process.StartInfo.RedirectStandardOutput = true;
        process.Start();
        process.StandardInput.WriteLine("az iot edge deployment list --hub-name jasonp2testhub  --resource-group v-jasonp2");
        string line = string.Empty;
        
        while (!process.StandardOutput.EndOfStream)
        {
            line = process.StandardOutput.ReadLine();
            
            Console.WriteLine(line);
        }
        process.WaitForExit();
        Console.ReadKey();
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM