Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run an Azure powershell cmdlet through a proxy server with credentials?

When I run the following Powershell cmdlet (from the Azure Management Tools Snapin):

get-osversions -subscriptionId **** -certificate (get-item cert:\CurrentUser\MY\******)

I get the following error message:

Get-OSVersions : The remote server returned an unexpected response: (407) Proxy Authenti cation Required. At line:1 char:15 + get-osversions <<<< -subscriptionId * -certificate (get-item cert:\CurrentUser\MY*****) + CategoryInfo : CloseError: (:) [Get-OSVersions], ProtocolException + FullyQualifiedErrorId : Microsoft.Samples.AzureManagementTools.PowerShell.HostedS ervices.GetOSVersionsCommand

Get-OSVersions : Object reference not set to an instance of an object. At line:1 char:15 + get-osversions <<<< -subscriptionId * -certificate (get-item cert:\CurrentUser\MY***) + CategoryInfo : CloseError: (:) [Get-OSVersions], NullReferenceException + FullyQualifiedErrorId : Microsoft.Samples.AzureManagementTools.PowerShell.HostedS ervices.GetOSVersionsCommand

It seems that the internet proxy server here is denying the script the access it requires.

I've had a good look around on the internet and it seems that there is no easy way around this problem since this cmdlet does not have a valid "-credentials" or proxy server parameter.

I know there is a 'Get-Credential' cmdlet but I don't think it helps. How would you pass the credential to the Azure cmdlet?

Can anyone think of any way to get around this issue?..

...other than using a different non-proxied internet connection?

I'm stumped.

Many Thanks for your time.

like image 861
window_eye Avatar asked Jul 25 '11 15:07

window_eye


People also ask

Which PowerShell command is used to authenticate to Azure?

Connect to Azure with an authenticated account for use with cmdlets from the Az PowerShell modules.

Does test Netconnection use proxy?

Test-NetConnect should use your proxy server if its correctly configured without having to specifically specify it.


2 Answers

Easier:

[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
like image 177
Zaaier Avatar answered Sep 23 '22 19:09

Zaaier


A few customers I know were successful using the method outlined here (Supporting Basic Auth proxies). If you need other proxy types, it follows the same pattern. The nice thing about this is it does not require changing the cmdlets.

like image 23
dunnry Avatar answered Sep 24 '22 19:09

dunnry