Created
December 20, 2016 22:50
-
-
Save max-vogler/d117608e9400264f98d2bac3a036b96a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "1.0.0-*", | |
"buildOptions": { | |
"debugType": "portable", | |
"emitEntryPoint": true | |
}, | |
"dependencies": { | |
"WindowsAzure.Storage": "7.2.1" | |
}, | |
"frameworks": { | |
"netcoreapp1.1": { | |
"dependencies": { | |
"Microsoft.NETCore.App": { | |
"type": "platform", | |
"version": "1.1.0" | |
} | |
}, | |
"imports": [ | |
"dnxcore50", | |
"portable-net45" | |
] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Net; | |
using Microsoft.WindowsAzure.Storage; | |
namespace ProxyTest | |
{ | |
public class ProxyTest | |
{ | |
public static void Main(string[] args) | |
{ | |
WebRequest.DefaultWebProxy = new MyProxy(); | |
HttpWebRequest.DefaultWebProxy = new MyProxy(); | |
var resp = HttpWebRequest.Create("https://www.google.org").GetResponseAsync().Result; | |
var body = new StreamReader(resp.GetResponseStream()).ReadToEnd(); | |
Console.WriteLine(body); // works through proxy | |
var connectionString = "DefaultEndpointsProtocol=https;AccountName=...;AccountKey=..."; | |
var account = CloudStorageAccount.Parse(connectionString); | |
var blobClient = account.CreateCloudBlobClient(); | |
var container = blobClient.GetContainerReference("test"); | |
var blob = container.GetBlockBlobReference("test"); | |
Console.WriteLine(blob.DownloadTextAsync().Result); // does not work, ignores proxy | |
Console.WriteLine("Done"); | |
} | |
public class MyProxy : IWebProxy | |
{ | |
public MyProxy() | |
{ | |
this.ProxyUri = new Uri("http://proxy.mycompany:8080"); | |
} | |
public Uri ProxyUri { get; set; } | |
public ICredentials Credentials { get; set; } | |
public Uri GetProxy(Uri destination) | |
{ | |
return this.ProxyUri; | |
} | |
public bool IsBypassed(Uri host) | |
{ | |
return false; /* Proxy all requests */ | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment