Azure Powershell Cmdlets through a proxy server

Hi,

I'm trying to run powershell cmdlets through a proxy server. If I just run the cmdlet I get a 407 error message.

Clearly some proxy server credentials are required.

The only way I found to pass the credentials to the Azure cmdlets is to create a 'powershell.exe.config' file at the following locations:

C:\Windows\SysWOW64\WindowsPowerShell\v1.0

C:\Windows\System32\WindowsPowerShell\v1.0

I've tried two diffierent .config files. The first contains:

 

 <system.net>
  <defaultProxy enabled="true" useDefaultCredentials="true">
   <proxy/>
   <bypasslist/>
   <module/>
  </defaultProxy>
 </system.net>

 

The second option I tried was:

 

<configSections>
 <sectionGroup name="proxyGroup">
  <section name="basicProxy"
       type="Proxy.Configuration.CustomProxySection, Proxy" />
 </sectionGroup>
</configSections>

<system.net>
 <defaultProxy enabled="true" useDefaultCredentials="false">
  <module type="Proxy.CustomProxy, Proxy"/>
 </defaultProxy>
</system.net>

<proxyGroup>  
 <basicProxy proxyHostAddress="Auto" proxyUserName="MyName" proxyUserPassword="MyPassword" />
</proxyGroup>

I've used these successfully before with Visual Studio apps but with the Azure cmdlets both options returned the following error message when I ran a powershell script containing a simple Azure cmdlet:

 

Get-OSVersions : The type initializer for 'System.ServiceModel.DiagnosticUtility' threw an exception.
At C:\Users\******.******\Desktop\azureconnect.ps1:3 char:15
+ get-osversions <<<< -subscriptionid****** -certificate C:\Users\******.******\******.cer
  + CategoryInfo     : CloseError: (:) [Get-OSVersions], TypeInitializationException
  + FullyQualifiedErrorId : Microsoft.Samples.AzureManagementTools.PowerShell.HostedServices.GetOSVersionsCommand

So the error 407 has gone, but now i'm stuck. I can't find much about this anywhere online.

I know that the powershell script works as I have tried running it successfully on a non-proxied machine.

Does anyone have any ideas as to why this isn't working?

Or any other suggestions for running the Azure Powershell cmdlets from behind a proxy server?

 

Many Thanks for your time

July 26th, 2011 6:15pm

From a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with us. Visit this link to see the various support options that are available to better meet your needs:  https://support.microsoft.com/oas/default.aspx?&c1=501&gprid=14928&&st=1&wfxredirect=1&sd=gn .
Free Windows Admin Tool Kit Click here and download it now
July 28th, 2011 3:39pm

You can do basically the same thing using .net classes and setup default proxy for you PowerShell script.

Just add

$proxy = [System.Net.CredentialCache]::DefaultCredentials
[System.Net.WebRequest]::DefaultWebProxy.Credentials = $proxy

at the beginning of your script blocks.

This solution works for my company's proxy quite well.

February 3rd, 2012 7:25am

Thanks for the reply. I eventually solved the issue by using fiddler to see which URLs were failing then adding the azure services to my I.E. proxy exceptions list. I have no idea why this worked, it shouldnt have worked, but it did. XD

A couple of weeks ago my company moved to a different proxy solution that appears to be alot more Azure Cmdlet friendly anyway.

Thanks for the suggestion anyway. I shall keep it in mind.

Free Windows Admin Tool Kit Click here and download it now
February 3rd, 2012 8:53am

Vasily - thanks for your solution, that worked perfectly for me! Especially useful when my company network people were less than helpful and didn't understand that azure is a service and not a server I was trying to connect to....
March 18th, 2015 6:47am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics