Anzal M S
Anzal M S

Reputation: 89

WebRole with Async/Await keyword not running on Azure

I am using the following piece of code to read a file from an http request.

var streamProvider = new MultipartMemoryStreamProvider();
streamProvider = await Request.Content.ReadAsMultipartAsync(streamProvider);   

I am using .net 4.0.So for the async/await keyword I have installed Microsoft.Bcl.Async NuGet package.This is working fine on my local machine.But when I try to upload the package to azure,the webrole fails to run.

Upvotes: 1

Views: 440

Answers (2)

Anzal M S
Anzal M S

Reputation: 89

Thanks for the response everyone. Instead of Microsoft.Bcl.Async, I used AsyncBridge for the async/await keywords and now it works locally as well as on the azure server.

Upvotes: 1

Stephen Cleary
Stephen Cleary

Reputation: 456322

Sorry, this will not work. You cannot use the Microsoft.Bcl.Async package on ASP.NET (including web roles). This is because ASP.NET needed some rewriting of some core types in order to support async/await, and you don't get this with the NuGet package.

On ASP.NET, you must target .NET 4.5 in order to use async/await.

Upvotes: 5

Related Questions