I have a .NET Core 2.2 Console app to connect to an Azure Storage Queue. It works on my computer, but I can't get it to work behind a corporate proxy. What do I need to do? (I anonymized the storage account name and key and the proxy hostname.)
.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>8.0</LangVersion>
<NullableContextOptions>enable</NullableContextOptions>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.21.0" />
<PackageReference Include="Microsoft.Azure.Storage.Queue" Version="10.0.1" />
</ItemGroup>
</Project>
Wrapper class:
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Queue;
using System.Threading.Tasks;
namespace Queue
{
public class Queue
{
public Queue(string connectionString, string queueName)
{
var storageAccount = CloudStorageAccount.Parse(connectionString);
var cloudQueueClient = storageAccount.CreateCloudQueueClient();
CloudQueue = cloudQueueClient.GetQueueReference(queueName);
}
private CloudQueue CloudQueue { get; }
public async Task<string> PeekAsync()
{
var m = await CloudQueue.PeekMessageAsync();
return m.AsString;
}
}
}
AppSettings.json
{
"StorageConnectionString": "DefaultEndpointsProtocol=https;AccountName=someAccount;AccountKey=someKey==;EndpointSuffix=core.windows.net"
}
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true">
<proxy
usesystemdefault="True"
proxyaddress="http://someProxy:8080"
/>
</defaultProxy>
</system.net>
</configuration>
App.config
because it is not handled. This is only valid for classic .NET. You need to set the proxy on each component. There is no global proxy setting (yet) in dotnet core. I faced the issue last week and found out that there is no proxy setting forCloudStorageAccount