1

How to a create command line (CLI) project. I like to add Azure CLI commands to end users in my Angular project. Presently I am tyring to do using C#. So please help me how to do CLI in Angular or C# to integrate my Azure CLI commands

2 Answers 2

1

You could run Azure CLI in C# like this:

string strCmdText;
strCmdText = "/C az login";
System.Diagnostics.Process.Start("CMD.exe", strCmdText);

/C: Carries out the command specified by string and then terminates.

Sign up to request clarification or add additional context in comments.

Comments

0

Angular cannot directly run the CLI commands as this would be a security flaw in the browser.

If you were to acquire a user token from an app registration, you could call Microsoft Graph APIs on behalf of a user. Very detailed explanation on how to do this here: https://learn.microsoft.com/en-us/graph/tutorials/angular

The other option is to call a C# Web API and run Microsoft Graph or the Azure CLI from the web server. Microsoft Graph SDK is the preferred mechanism from C#, but you could also use System.Diagnostics.Process to launch and run Azure CLI commands.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.