Dependency Injection In Azure Functions V2

With the Azure Functions v2 runtime, supporting .NET Core it has become easier to do dependency injection. It can be done in a similar way that ASP.NET Core does via Microsoft.Extensions.DependencyInjection.

Read More

Azure Event Grid events across Azure subscriptions

Consider a scenario where you need to listen to Azure resource events happening in one Azure subscription from another Azure subscription. A use case for such a scenario can be when you are developing a solution where you listen to events happening in your customers’ Azure subscriptions, and then you need to handle those events from an Azure Function or Logic App running in your subscription. A solution for such a scenario could be:

  1. Create an Azure Function in your subscription that will handle Azure resource events received from Azure Event Grid.
  2. Handle event validation in the above function, which is required to perform a handshake with Event Grid.
  3. Create an Azure Event Grid subscription in the customers’ Azure subscriptions.
Read More

How to Test Azure Logic Apps

Azure Logic Apps are a great solution to write workflows of the business processes, and that too without writing any code. As a result, unit tests can not be written because there’s no code to write unit tests against. How do one go around testing a logic app then?

Read More

Create a dotnet core Azure Function

Latest version of Visual Studio Extension Azure Functions and Web tools helps you create pre-compiled C# Azure Functions, and lets you write functions as a C# library. Being a pre-compiled function it has better performance while starting up. Along with that, it lets you use Webjobs attributes for declaring bindings, thus not needing a functions.json file. And, it lets you debug and run azure functions locally.

Read More

Blocking all external access and securing Azure Functions

If you’re developing a solution with micro services architecture with Azure, there are chances you’ve been using Azure Functions to develop a service. For example, If you’re solution can involving sending email alerts. One of the microservices here can be Email Service. This can further be broken down into two micro services. One to enqueue mail message to Azure storage queue. This can be a Http Triggered function. Second one can be a Queue trigerred function that prcesses these messages and actually sends the email, using a third party API.

Read More

An ASP.NET Picasa Image Gallery

Few days back I was thinking of creating an Image Gallery of the collection of photos I have. Although, there are multiple options available over the internet that you can download and get ready on the go; most of them involves saving the images on your own server. But what I was more concerned was to just have a display only image in my web site to showcase my photos to the word. And, I wanted to make use of one of my social network account – Facebook, Google+, Twitter or Flickr to host the images.

Read More

Changing Drive Letter of an Azure Drive (aka X-drive)

Sometimes it might be necessary that you want your Azure drive to be always mounted on a fixed drive letter. Consider a scenario of an Azure VM Role where you need to mount an azure drive for data persistance and your VM demands the same letter for you azure drive, e.q. you installed SQL Server on your VM Role and for mdf files you specified azure drive as path so as to make the data persist.
Read More

Data Persitence in Azure VM Role

Azure VM Role involves creating a base image, uploading it to Azure using csupload, and then creating a servic model in Visual Studio to point to the uploaded base image.

Read More

Startup Tasks in Azure Virtual Machine (VM ) Role

Since the release of Windows Azure SDK 1.3 we can now have startup tasks defined in the *ServiceDefinition *file for web/worker roles. However, this is not allowed for a Virtual Machine role. So what to do in case you need to have some tasks/scripts to be run on your VM Role’s startup? For example, your VM Role runs some software applications that require some configuration information that can be available only at run time.

Read More

Azure VM Role CSUPLOAD Error 0x80070070 Cannot prepare VHD

Today I was trying to upload my base image to Azure via csupload so that i can attach this vhd to one of my virtual machine (VM) role. However, I got a strange error with no details. I kept on looking for the reason and finally I found the solution. The error was as below:
Unexpected Error 0x80070070
Cannot prepare VHD C:\Users\user1\Desktop\baseimage.vhd
## Reason: The reason for this error as i discovered was that the disk from where it was uploaded was full. When you use csupload it uses temporary directory for preparing image and by default it uses the location from where you are uploading your base image. So if this disk is full you get this error.
Read More

Guide to Windows Azure Connect

Building applications for cloud and hosting them on cloud is one of the great things that happened in recent times. However, you might be having number of existing applications that you wish to migrate to cloud, but you do not want to move your database server to the cloud. Or you want to create a new application and host it in the cloud, but this new application needs to communicate with your existing on-premise applications hosted in your enterprise’s network. Other case might be that your new application that you wish to host in cloud will rely for its authentication on your enterprise’s Active Directory.

Read More

What is Relying Party (RP)

An application that accepts tokens from an
STS is called as a Relying Party (or RP). In modern scenarios, web applications use WIF and accept tokens from an STS to manage authentications process.

Read More

What are Claims

The security tokens generated by
STS contain various attributes based on which a grant/deny access is provided or based on which user experience is customized. These attributes are called as Claims.

Read More

What is Security Token Service (STS)

Traditionally, access control was implemented within the main application by writing a code against user’s credentials to authenticate them and based on their attributes grant/deny access to various resources. This required application developers to be skilled in implementing security and writing a code which is hard to implement and maintain.

Read More

What is Passive Federation

When i started working with ACS on Appfabric I kept on encountering various terminologies, one of them was Passive Federation and it was widely used. I could understand the term Federation but passive was not clear to me ever.

Read More

Debug SSIS Script Component

While working with your SSIS package, have not you ever tried debugging a script component transformation by putting a breakpoint in the VB code? Well, i did and found that, unfortunately, it does not work.

Read More

Downloading files with ASP.NET using Save As Dialog

This article explains how to download a file that is stored in the database with the possibility of forcing the browser to open a “Save As” dialog box to save the file on to the client system. </p>

The content of the file is stored in a column of a table of image data type.</p>

Such a dialog-box for saving a file can be displayed by using HttpContext.Current.Response property. </p>

HttpContext is a class that encapsulates all HTTP-specific information about an individual HTTP request. The property HttpContext.Current gets the HttpContext object for the current HTTP request. </p>

Here is an example: </p>

1. HttpContext.Current.Response.Clear();</p>

2. HttpContext.Current.Response.ContentType = "file"; </p>

3. HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + fileName);</p>

4. // Remove the charset from the Content-Type header.</p>

5. HttpContext.Current.Response.Charset = "";</p>

6. byte [] buffer = (byte[])(dsFile.Tables[0].Rows[0]["FILE_CONTENT"]);</p>

7. HttpContext.Current.Response.BinaryWrite(buffer);</p>

8. // End the response.</p>

9. HttpContext.Current.Response.End();</p>

Line 1 clears all content output from the buffer stream.</p>

Line 2 sets the HTTP MIME type for the output stream. The default value is "**text/html**". As we want to store it as a file to the client system we specify it as “**file**”. The **AddHeader****(****) **method in Line 3 is used to add an HTTP header to the output stream. It accepts two parameters. First parameter is the name of the HTTP header to add value to and second is the value itself. In our case the parameter name is “**content-disposition**” and value is sent as **"****attachment****"** along with the file name. This is what that causes the opening of save file dialog. If we provide value of content-disposition as “inline” instead of save file dialog the file will be opened in the associated application. </p>

In the Line 7 we are actually writing the contents of the file, as binary characters, to the HTTP output stream. Method **BinaryWrite****()** is used for this purpose. This method takes a parameter buffer which is a byte array containing bytes to be written to the HTTP output stream. In our case the content of this buffer are fetched from the database into a dataset **dsFile** with column “**FILE_CONTENT**” corresponding to the bytes to be written. </p>

The **End()** method in Line 9, sends all currently buffered output to the client, stops execution of the page, and raises the **Application_EndRequest** event. This is when we see a message asking us to save or open the file, displaying the information about the file, like file type, file name.</p>

On clicking save, the save file dialog is opened where we can save the file to our system with the name that we have provided in the line 3 or we can provide a new name also.</p>

Read More

Output Paramaters in OLE DB Command in SSIS

Today when i was nearly at the verge of finishing my SSIS package i just found out that i really can not complete it at the moment. I am having lot of validations on the input data, lot of look ups to get the reference values and after that i need to insert the rows into a SQL server database. It is not simple insertion, there is a big logic behind inserting rows, checking if the rows containing individual numbers form a sequence so that those can be inserted into a range rather than individual entries. Not only that i need to check if that number is already in the table in some range, if yes i need to discard it, redirect that row to an error output file.

Read More

Using Temp Tables in SSIS Package Development

Often while working in a SSIS package you will require to temporary hold your data in a staging table in one of the Data Flow Tasks and then in another task you will require to fetch data from the staging table, perform transformations and load it and delete the staging table.

Read More

Sending Mails in .NET framework 2.0 : new namespace System.Net.Mail

If you have used System.Web.Mail namespace in .NET 1.x for sending emails programmatically, expect a surprise. All classes within this namespace have been deprecated in favor of the new System.Net.Mail namespace. System.Net.Mail contains classes such as MailMessage, Attachment, MailAddress, SmtpClient, etc to help us send emails in the 2.0 world. The features provided by this namespace, in a nutshell, are given below.</p>


  • MailMessage is the main class that represents an email message. </li>
  • Use MailAddress class to represent the sender and each recipient. </li>
  • Use SmtpClient class to connect to the SMTP server and send the email, both synchronously and asynchronously. </li>
  • Use AlternateView class to create the email content in alternate formats, say one in HTML and other plain text, to support different recipient types. </li>
  • Use LinkedResource class to associate an image with the email content. </li>
  • SmtpPermission class and SmtpPermissionAttribute can be used for code access security. </li>


    To know more about some of these classes, [read this article](</p>

Read More

Code Analysis in Visual Studio 2005 Team Suite

If you are using VS.NET 2005 Team Suite, code analysis is built into the IDE itself. In older version of VS.NET, you might have used FxCop externally for comparing against pre-defined rules or would have integrated with the IDE by adding FxCop as an Add-In.

Read More