Posts

Showing posts with the label Azure Function

C#: How to I extend the timeout of a WebClient call? (30 seconds is just not long enough)

My Azure function is calling web services that take longer than 30 seconds to complete, so I needed to extend the default timeout the WebClient class. I created the following base class: using System; using System.Net; namespace MyHelpers {     public class MyWebClient : WebClient     {         public int Timeout { get; set; }         public WebDownload() : this( 180000 ) { }         public WebDownload(int timeout)         {             this.Timeout = timeout;         }         protected override WebRequest GetWebRequest(Uri address)         {             var request = base.GetWebRequest(address);             if (request != null)             {             ...

Azure: How do I delete my function?

Image
I have been playing with Azure functions (which are great), but there does not seem to be an intuitive way to delete them. The first option (which requires forethought) is to create its own Resource Group (with the associated storage accounts) and delete the RG. Easy - if you knew it was coming and planned for it. The other option is go into 'Function App Settings'  -> 'Go to App Service Settings'. You can then delete the app.

Azure Function: Call a web service and return the result as a class

My current project is using Azure Functions as action triggers. Thanks to some nifty work from the Visual Studio team, we now have a local development environment. The following POC function will call a Web API (configured through API Management) and convert the resultant JSON into a class object. 1. Create a 'Model' solution that stores the class to be used. I called my MyModel. My class is called ApiResult. namespace MyModel {     public class ApiResult     {         public string Message { get; set; }     } } 2. Create an API to invoke using MyModel; using System.Web.Http; namespace MyControllers {     public class MyController : ApiController     {         [System.Web.Http.HttpGet]         [System.Web.Http.Route("api/myapiendpoint")]         public ApiResult ValidateFile()         {       ...