官术网_书友最值得收藏!

How to do it...

  1. Create a new Azure Function by choosing the QueueTrigger-C# from the templates.
  2. Provide the following details after choosing the template:
    • Name your function: Please provide a meaningful name such as CreateProfilePictures.
    • Queue name: Name of the Queue which should be monitored by the Azure Function. Our previous recipe created a new item for each of the valid requests coming to the HTTP trigger (named RegisterUser) into the userprofileimagesqueue Queue. For each new entry of a queue message to this Queue storage, the CreateProfilePictures trigger will be executed automatically.
    • Storage account connection: Connection of the storage account where the Queues are located.
  3. Review all the details, and click on Create to create the new function.
  4. Navigate to Integrate tab then click on New Output then choose Azure Blob Storage then click on the Select button.
  5. In the Azure Blob Storage output section, provide the following:
    • Blob parameter name: Set it to outputBlob
    • Path: Set it to userprofileimagecontainer/{rand-guid}
    • Storage account connection: Choose the storage account where you would like to save the Blobs:
  1. Once you provide all the preceding details, click on the Save button to save all the changes.
  2. Replace the default code of the run.csx file with the following code:
        using System;
public static void Run(Stream outputBlob,string myQueueItem,
TraceWriter log)
{
byte[] imageData = null;
using (var wc = new System.Net.WebClient())
{
imageData = wc.DownloadData(myQueueItem);
}
outputBlob.WriteAsync(imageData,0,imageData.Length);
}
  1. Click on the Save button to save the changes.
  2. Let's go back to the RegisterUser function and test it by providing firstname, lastname, and ProfilePicUrl fields as we did in the Saving the profile images to Queues using Queue output bindings recipe.
  3. Now, navigate to the Azure Storage Explorer, and look at the Blob container userprofileimagecontainer. You will find a new Blob as shown in the following screenshot:
  1. You can view the image in any tool (such as MS Paint or Internet Explorer).
主站蜘蛛池模板: 喀喇沁旗| 高清| 德阳市| 大洼县| 富蕴县| 年辖:市辖区| 涿州市| 正镶白旗| 横山县| 平昌县| 惠来县| 大石桥市| 中山市| 台安县| 华蓥市| 北宁市| 伊川县| 金昌市| 郑州市| 绿春县| 当雄县| 浦北县| 玉屏| 东乡县| 浏阳市| 卓尼县| 三明市| 荥阳市| 商城县| 雷波县| 甘肃省| 绵竹市| 玛纳斯县| 鄯善县| 沙雅县| 漳浦县| 岢岚县| 探索| 都匀市| 新泰市| 连山|