【问题标题】:Runing a custom executable on PDF files stored in azure blob storage with azure web app front-end使用 azure Web 应用程序前端对存储在 azure blob 存储中的 PDF 文件运行自定义可执行文件
【发布时间】:2017-10-20 05:04:15
【问题描述】:

我有一个使用 ASP.NET 4.5/C# 构建的 Web 应用程序,并作为 Web 应用程序托管在 azure 中。该站点允许用户上传 PDF 文件,然后将这些文件存储在 azure blob 容器中,以后可以根据需要通过网站下载。到目前为止一切顺利。

我们现在有一个新要求,涉及使用自定义 win32 可执行文件处理这些文件,并且网站必须知道处理是否成功。这个exe有一个安装文件,必须安装在目标机器上才能使用。

我一直在摸索如何构建此功能。我遇到过许多文章,它们告诉我们需要 Worker Role,或者需要 VM。但是所有的文章似乎都很抽象。

鉴于可执行文件的安装程序需要手动干预,我认为 Azure VM 是可行的方法。但是网络应用程序将如何与此通信。如何将处理结果通知网络应用?

【问题讨论】:

    标签: azure-web-app-service azure-storage azure-blob-storage


    【解决方案1】:

    您不能在 Azure Web 应用中安装此类软件,因为 Web 应用是沙盒化的。因此,您将无法运行该设置exe。

    对于此类处理,您需要在虚拟机或网络/工作者角色中运行应用程序的该部分。

    【讨论】:

      【解决方案2】:

      但是网络应用程序将如何与此通信。如何将处理结果通知网络应用?

      Azure Queue storage 可以满足您的要求。它可以在应用程序组件之间提供云消息传递。您的 VM 可以将处理结果写入队列,而您的 Web 应用程序可以从同一队列中读取处理结果。

      要将新消息添加到队列中,您可以参考以下代码。

      // Retrieve storage account from connection string.
      CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
          CloudConfigurationManager.GetSetting("StorageConnectionString"));
      
      // Create the queue client.
      CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
      
      // Retrieve a reference to a queue.
      CloudQueue queue = queueClient.GetQueueReference("myqueue");
      
      // Create the queue if it doesn't already exist.
      queue.CreateIfNotExists();
      
      // Create a message and add it to the queue.
      CloudQueueMessage message = new CloudQueueMessage("Hello, World");
      queue.AddMessage(message);
      

      在您的网络应用程序中,您可以创建一个QueueTrigger WebJob,如果有任何新消息添加到队列中,该作业将立即执行。

      public static void ProcessQueueMessage([QueueTrigger("myqueue")] string processResult, TextWriter log)
      {
         //You can get the processResult and do anything needed here
      }
      

      【讨论】:

        猜你喜欢
        • 2020-01-16
        • 2012-03-24
        • 2019-04-04
        • 2021-07-09
        • 2012-05-20
        • 2015-08-05
        • 2017-03-26
        • 2023-04-08
        • 1970-01-01
        相关资源
        最近更新 更多