GVKun编程网logo

Azure Durable Function 通过邮件发送 EventPostUri(azure sendgrid)

27

在本文中,您将会了解到关于AzureDurableFunction通过邮件发送EventPostUri的新资讯,同时我们还将为您解释azuresendgrid的相关在本文中,我们将带你探索AzureD

在本文中,您将会了解到关于Azure Durable Function 通过邮件发送 EventPostUri的新资讯,同时我们还将为您解释azure sendgrid的相关在本文中,我们将带你探索Azure Durable Function 通过邮件发送 EventPostUri的奥秘,分析azure sendgrid的特点,并给出一些关于Azure Durable Function CPU 资源、Azure Durable Functions 将扇出与函数链相结合、Azure Function & AWS Function With C#、Azure Function long duration and App Service Plan, Durable function的实用技巧。

本文目录一览:

Azure Durable Function 通过邮件发送 EventPostUri(azure sendgrid)

Azure Durable Function 通过邮件发送 EventPostUri(azure sendgrid)

如何解决Azure Durable Function 通过邮件发送 EventPostUri?

我为 Azure 广告中的用户配置构建了一个持久功能。 我的目标是检查可用许可证的编排功能。如果所有许可证都在使用中,该函数将等待外部事件并重试许可证分配。

为了实现这一点,我想发送一封包含购买新许可证请求和“SendEventPostUri”的电子邮件。

我的问题是我找不到在编排函数中读取 SendEventPostUri 的方法。

这可能吗?

解决方法

看起来您可以通过 package com.org.projectb.dataModels.user does not exist 接口的 SendEventPostUri 方法获取 CreateHttpManagementPayload

URI 的格式如下

IDurableOrchestrationClient

并且您需要为需要引发的事件替换 http://host/runtime/webhooks/durabletask/instances/instanceId/raiseEvent/{eventName}?taskHub=TestHubName&connection=Storage&code=*****

这是我用来检查这个的示例代码

{eventName}

Azure Durable Function CPU 资源

Azure Durable Function CPU 资源

如何解决Azure Durable Function CPU 资源?

我是持久函数的新手,并且已经建立了一个基于消耗(无服务器)的函数计划,我在其中安装了一个持久函数。

该函数用于计算大量数学方程并将结果写入数据矩阵。使用 4 个内核(8 个处理器)运行通常需要 1 到 5 分钟。输出写入 MysqL 数据库,客户端应用轮询该数据库以检索更新和结果。

一切正常,直到我尝试对其进行缩放...

我注意到每次运行它时,它都提供对两个处理器的访问。但是,如果我从两个客户端同时调用它两次,那么每个客户端似乎只能获得 1 个处理器,并且运行速度减半。三个客户端调用需要更长的时间......那么缩放在哪里?

请注意,我试过扇出,但速度太慢(可能是因为计算中的数据量很大)。

我的问题是:-

当它扩展到 100 个同时调用时会发生什么?

是否有更有用的计划可以让我每次执行最少 N 个处理器?

它可能会达到 500 甚至 1000 个同时调用……Azure 能应付这个吗?

我想过设置 100 个相同的函数(显然具有不同的名称)并为每个客户端轮流调用它们......这行得通吗?如果是这样,那么需要它似乎很奇怪。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

Azure Durable Functions 将扇出与函数链相结合

Azure Durable Functions 将扇出与函数链相结合

如何解决Azure Durable Functions 将扇出与函数链相结合?

我有一个持久函数应用程序,用于根据 FileName 属性以不同方式处理提交的项目。 orchestrator 功能类似于以下内容,但以下是一个简化示例,用于说明我的场景。

基本上,我根据用户提交的数据中 FileName 属性的扩展名进行不同的函数链接。

             InputData inputData = context.GetInput<InputData>();
        List<OutputData1> outputData1List = new List<OutputData1>();
        List<OutputData2> outputData2List = new List<OutputData2>();
        if (Path.GetExtension(inputData.FileName) == ".exa")
        {
            Func1Data func1Data = new Func1Data(inputData);
            outputData1List.Add(await context.CallActivityAsync<OutputData1>("Function1",func1Data));

            Func2Data func2Data = new Func2Data(inputData);
            outputData1List.Add(await context.CallActivityAsync<OutputData1>("Function2",func2Data));

            Func3Data func3Data = new Func3Data(inputData);
            outputData2List.Add(await context.CallActivityAsync<OutputData2>("Function3",func3Data));
        }
        if (Path.GetExtension(inputData.FileName) == ".exb")
        {
            Func2Data func2Data = new Func2Data(inputData);
            outputData1List.Add(await context.CallActivityAsync<OutputData1>("Function2",func3Data));
        }
        if (Path.GetExtension(inputData.FileName) == ".exc")
        {
            Func3Data func3Data = new Func3Data(inputData);
            outputData2List.Add(await context.CallActivityAsync<OutputData2>("Function3",func3Data));
        }
        if (Path.GetExtension(inputData.FileName) == ".exd")
        {
            Func4Data func4Data = new Func4Data(inputData);
            outputData2List.Add(await context.CallActivityAsync<OutputData2>("Function4",func4Data));
        }
        return new { output1 = outputData1List,output2 = outputData2List };

这适用于单个文件,但我现在还想向我的函数 App 添加第二个客户端函数,该函数接受包含一组文件输入的一批文件,并以相同的方式但同时处理它们。现在为了允许批处理中的每个文件同时处理,我需要扇出/进入。但我不确定如何在每个文件类型的基础上维护函数链的同时实现这一点。下面让我更近了一步,但我怀疑有更好的方法来实现这一点。

        public static async Task<Object> Runorchestrator([orchestrationTrigger] IDurableorchestrationContext context)
    {
        List<InputData> batchData = context.GetInput<List<InputData>>();
        List<OutputData1> outputData1List = new List<OutputData1>();
       // List<OutputData2> outputData2List = new List<OutputData2>();

        var concurrentTasks = new List<Task<outputData2>>();

        foreach (InputData inputData in batchData)
        {
            if (Path.GetExtension(inputData.FileName) == ".exa")
            {
                Func1Data func1Data = new Func1Data(inputData);
                outputData1List.Add(await context.CallActivityAsync<OutputData1>("Function1",func1Data));

                Func2Data func2Data = new Func2Data(inputData);
                outputData1List.Add(await context.CallActivityAsync<OutputData1>("Function2",func2Data));

                Func3Data func3Data = new Func3Data(inputData);
                concurrentTasks.Add(context.CallActivityAsync<OutputData2>("Function3",func3Data));
            }
            if (Path.GetExtension(inputData.FileName) == ".exb")
            {
                Func2Data func2Data = new Func2Data(inputData);
                outputData1List.Add(await context.CallActivityAsync<OutputData1>("Function2",func3Data));
            }
            if (Path.GetExtension(inputData.FileName) == ".exc")
            {
                Func3Data func3Data = new Func3Data(inputData);
                concurrentTasks.Add(context.CallActivityAsync<OutputData2>("Function3",func3Data));
            }
            if (Path.GetExtension(inputData.FileName) == ".exd")
            {
                Func4Data func4Data = new Func4Data(inputData);
                concurrentTasks.Add(context.CallActivityAsync<OutputData2>("Function4",func4Data));
            }
        }
        var outputData2List = await Task.WhenAll(concurrentTasks);
        return new { output1 = outputData1List,output2 = outputData2List };
    }

不是按顺序处理每个链中的第一个函数,我可以从每个函数链序列中创建一个新的任务,并批量处理这个吗?如果是这样,有人可以向我提供执行此操作的语法示例吗?

谢谢!

解决方法

子编排有效。

    public static async Task<Object> BatchRunOrchestrator(
    [OrchestrationTrigger] IDurableOrchestrationContext context)
    {
        List<InputData> batchData = context.GetInput<List<InputData>>();
        var concurrentTasks = new List<Task<Object>>();
        foreach (InputData inputData in batchData)
        {
            concurrentTasks.Add(context.CallSubOrchestratorAsync<BlobFileCombinedFunctionResults>("OtherOrchestration",inputData));
        }
        var results = await Task.WhenAll(concurrentTasks);
        return results;
    }

Azure Function & AWS Function With C#

Azure Function & AWS Function With C#

Using C# with Azure Functions

Two important prerequisites need to be met to build Azure Functions applications with C#:

  1. Have an active Microsoft Azure subscription. If you don’t have one already, you can create a free account.
  2. Get an Azure Storage account. If you don’t have this too, you can create a storage account by signing into the Azure portal.

As a C# developer, you are already familiar with the various tools for building your applications which include Visual Studio Code and Visual Studio IDE. Both tools help create applications with Azure Functions, depending on whichever one you are most comfortable with.

Let’s dig a little deeper into these two tools:

Serverless And C# - What You Need To Know

Visual Studio Code

Visual Studio Code is a lightweight but powerful code editor with different versions available for Windows, Linux, and MacOS.

To build apps for Azure functions, you will need to get Azure Tools for Visual Studio Code which will give you convenient commands through which you can access or create resources directly from the VS Code editor.

To set up Azure Tools, install the Azure Extension Pack by firing up your editor and navigating to the extension marketplace on the left side menu. The extension marketplace interface in VS Code should look like this:

When you are done with the setup of Azure for VS Code, login to Azure from the code editor by firing the Command Palette with the commands CTRL+Shift+P and typing “Azure: Login” in the text field that appears. Click the corresponding result that appears and a code will be generated by the editor with instructions on how to complete the process.

Another important extension if you will be developing in C# with VS Code is the C# for Visual Studio Code. As at the time of this writing, the extension supports basic debugging capabilities full details of which can be found here.

Serverless And C# - What You Need To Know

Visual Studio 2017 IDE

From version 15.5, Azure Development workload comes bundled with Azure Functions tools. This implies if you plan on installing the latest version of Visual Studio 2017, you need to include Azure Development workload in your installation process.

Your installation window should look like this:

Once installation is complete, sign in to your Microsoft account in Visual Studio and create a new Azure Functions project and you are good to go.

Serverless And C# - What You Need To Know

Image Source

Now that we’ve highlighted what you need to know if you want to build serverless functions in C# with Azure functions, let’s move over to discussing what you need to begin running serverless apps on the AWS Lambda serverless framework.

Serverless And C# - What You Need To Know

Using C# with AWS Lambda

AWS Lambda is the compute part of the AWS serverless architecture, but contains zero administration. It is one of the most popular options for serverless and though it was launched by AWS in 2014, support for the .NET Core 1.0 runtime was announced in 2016 and the .NET Core 2.0 runtime in 2018. At this point, it is important to note .NET Core is different from the .NET framework and here are a few reasons AWS chose .NET Core over the .NET framework:

  • .NET Core is the new redesigned version of .NET that focuses on more modern applications and in particular, cloud-enabled applications which has significant benefits when writing Lambda functions
  • .NET Core was designed with a modularized design which means you only get to include the part of .NET you will need when writing your Lambda functions. This leads to lesser memory usage and since Lambda charges you for memory usage, lesser memory demands by your functions will lead to lesser costs to you for using AWS Lambda.
  • .NET Core is open-source and has been validated against Amazon Linux — the underlying platform for AWS Lambda making it very possible for AWS to respond to security issues that might arise with using it.
  • Lastly and more importantly, with .NET Core, you can now write your C# code on any platform as opposed to earlier days with .NET where you could write C# code on only Windows environments

To begin building Lambda functions in C# with Visual Studio you will need to understand AWS Lambda has a laid-down pattern for authoring code for your Lambda function. This pattern includes the following concepts:

  • Handler - the handler function is a function called by AWS Lambda to begin execution of your Lambda function. AWS Lambda passes any input data into this function as the first parameter and passes a context object as a second parameter.
  • Context Object - is the second parameter passed into the handler function and it provides information through which your code interacts with AWS Lambda.
  • Logging - a good logging system is an important component of a well-written function. AWS Lambda writes these logs to CloudWatch Logs.
  • Exceptions 

Now that we know the framework for writing for AWS Lambda, let’s see how all this work together.  

Writing C# Code for AWS Lambda with Visual Studio

A few prerequisites are required to begin writing code for Lambda functions:

  • Have an AWS account. If you don’t have one, you can create an AWS account here
  • Download and Install Visual Studio IDE 2017.

Note: older versions of Visual Studio will require an additional installation of .NET Core for Windows

  • Download and Install the AWS Toolkit for Visual Studio

Once you’ve installed all prerequisites, open Visual Studio and fill in the AWS credentials on the Getting Started with the AWS Toolkit for Visual Studio window displayed next to the Start Page tab. The credentials (Access Key and Secret Key) can be gotten by following the instructions outlined in the window  

Serverless And C# - What You Need To Know

Image Source

With that all set, let’s move on to build our Lambda project.

Create a .NET Core Lambda Project

  • Open Visual Studio IDE and go to File > New > Project
  • On the Installed Pane, Click Visual C# and then AWS Lambda Project (.NET Core) as shown below:
  • Fill out the project name with a name of your choice and click OK, leaving the defaults as they then move on to selecting the type of Lambda project you want to build.
  • Click Finish to create the project and review the project code and structure.
  • An important file created with your project is the aws-lambda-tools-defaults.json file where you set your function handler as well as other options. The contents of the file should look like this:

Publishing to AWS Lambda

The next step to running our code on AWS Lambda is to publish it. This is done after the code has been reviewed and you are convinced it is good to go. The following steps outline what you need to do to get your code published.

  • On the right side, you can see the project. There in the Solution Explorer click Publish to AWS Lambda
  • Next, fill in the Function Name in the Upload to AWS Lambda window that appears. You can give any preferred name to your function at this point. Once you are done, click Next.
  • On the Advanced Function Details page, fill the Role Name section with a role associated with your AWS account. This is an important field to fill before we can proceed to the next stage of the upload process. Other sections include the VPC section (only useful if your function will be accessing resources on Amazon VPC) and the Environment section.
  • Once your function begins uploading, a window is displayed showing the status of the upload after which a function view page is displayed where you can test your function and view logs respectively.
  • The Invoke button begins testing the function while Log output displays output from the test. These logs are also saved into CloudWatch Logs in AWS where more details on the logs can be viewed.

Conclusion

Now, you have a quick peek into what you need to know to build and publish serverless applications with the powerful C# programming language. Though at Dashbird, we are more inclined towards AWS Lambda, there is nothing stopping you from exploring both the Microsoft Azure functions and AWS Lambda options in getting that serverless infrastructure for your applications.

Azure Function long duration and App Service Plan, Durable function

Azure Function long duration and App Service Plan, Durable function

如何解决Azure Function long duration and App Service Plan, Durable function?

我正在准备 AZ-204 认证。

我们想在很长一段时间内执行一个函数。解决方案(在 Microsoft docs 中)是使用应用服务计划或持久功能

在一次练习测试中,我发现以下问题的答案令人困惑:

“您开发了一个 HTTP 触发的 Azure Function 应用程序来处理 Azure 存储 blob 数据。该应用程序是使用 blob 上的输出绑定触发的。 该应用程序在四分钟后继续超时。应用程序必须处理 blob 数据。 您需要确保应用不会超时并处理 blob 数据。” 建议答案:

解决方案 1:将应用配置为使用应用服务托管计划并启用始终开启设置。 应该是YES还是NO??

解决方案 2:使用 Durable Function 异步模式来处理 blob 数据。 应该是 YES 还是 NO ??

解决方案 3:将 HTTP 触发器有效负载传递到 Azure 服务总线队列,由队列触发器函数处理并立即返回 HTTP 成功响应。 应该是 YES 还是 NO ??

根据我所准备的,三个答案都是正确的。谁能确认?

解决方法

我不完全理解该函数的触发器。从文本来看,它似乎是一个 HTTP 触发器和一个 blob 触发器?但我会假设它是一个 HTTP 触发器,可以处理超过 4 分钟的 blob 数据。 对于这种情况,正确答案是 NO、YES、YES imo。

解决方案 1: https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale#timeout 无论应用服务计划是什么,HTTP 触发器的最大超时时间都是 230 秒。

解决方案 2: https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview?tabs=csharp#async-http 如果您像此模式的文档中所说的那样立即返回响应,我会认为这是正确的。持久函数我用的比较多,肯定能解决问题,还可以查看状态,很容易取消。

解决方案 3: 由于我们将我们的工作从 HTTP 函数分离到队列,它能够运行 10 无穷大(取决于计划),因此这也被认为是正确的。函数的一个关键概念是分离工作和队列的能力是最常见的方法。从架构上讲,我可能更喜欢这种方法,但持久函数也能工作。

如果您有任何需要澄清的问题,请询问并祝考试顺利。

今天关于Azure Durable Function 通过邮件发送 EventPostUriazure sendgrid的介绍到此结束,谢谢您的阅读,有关Azure Durable Function CPU 资源、Azure Durable Functions 将扇出与函数链相结合、Azure Function & AWS Function With C#、Azure Function long duration and App Service Plan, Durable function等更多相关知识的信息可以在本站进行查询。

本文标签: