Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

421
Visualizações
Use 'Connect-AzAccount' command of PowerShell in C#

I want to connect to Azure the same way I log in using Powershell commands. Since I have not found any API to do that with .NET, I thought that a good idea would be to execute PS scripts with.NET.

I have already installed the Powershell for azure on my laptop

Install-Module -Name Az -AllowClobber

I also tried to use the 'Connect-AzAccount' command just with the Windows Powershell of my PC and it works fine.

So, I tried the following in Visual Studio:

using System.Management.Automation;

namespace AzureTestVM
{
    class Program
    {

        static void Main(string[] args)
        {
            PowerShell ps = PowerShell.Create().AddCommand("Connect-AzAccount");
            ps.Invoke();
        }
    }
}

The problem is that I get the following error :

Unhandled Exception: System.Management.Automation.CmdletInvocationException: Method
'get_SerializationSettings' on type' 
Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient 'of assembly' 
Microsoft.Azure.PowerShell.Clients.ResourceManager, Version = 1.0. 0.0, Culture = neutral,    
PublicKeyToken = 31bf3856ad364e35 'does not have an implementation. --->
 System.TypeLoadException: Method 'get_SerializationSettings' on type' 
Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient 'of assembly' 
Microsoft.Azure.PowerShell.Clients.ResourceManager, Version = 1.0.0.0, Culture = neutral, 
PublicKeyToken = 31bf3856ad364e35 'does not have an implementation.
over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda