Perform the following steps:
- Open the FunctionAppInVisualStudio Azure Function app in Visual Studio, and then add a new function by right-clicking on the FunctionAppInVisualStudio project. Click on Add | New Azure Function, which opens a popup. Here, for the name field, enter BlobTriggerCSharp and then click on the Add button.
- This opens another popup, where you can provide other parameters, as shown in the following screenshot:
- In the storage account connection settings, provide AzureWebJobsStorage as the name of the connection string, and also provide the name of the Blob container (in my case, it is cookbookfiles) in the Path input field, then click on the OK button to create the new Blob trigger function. A new Blob trigger function gets created, as shown in the following screenshot:
- If you remember the Building a backend Web API using HTTP triggers recipe from Chapter 1, Developing Cloud Applications Using Function Triggers and Bindings, the Azure Management Portal allowed us to choose between a new or existing storage account. However, the preceding dialog box is not connected to your Azure subscription. So, you need to navigate to the storage account and copy the connection string, which can be found in the Access Keys blade of the storage account in the Azure Management Portal, as shown in the following screenshot:
- Paste the connection string in the local.settings.json file, which is in the root folder of the project. This file is created when you create the function app. After you add the connection string to the key named AzureWebJobsStorage, the local.settings.json file should look like that shown in the following screenshot :
- Open the BlobTriggerCSharp.cs file and create a breakpoint, as shown in the following screenshot:
- Now press the F5 key to start the job host, as shown in the following screenshot:
- I have added a new Blob file using Azure Storage Explorer, as shown in the following screenshot:
- As soon as the Blob has been added to the specified container (in this case, it is cookbookfiles), which is sitting in the cloud in a remote location, the job host running in my local machine detects that a new Blob has been added and the debugger hits the function, as shown in the following screenshot: