Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure函数应用程序powershell触发两次/三次_Azure_Powershell_Azure Functions - Fatal编程技术网

Azure函数应用程序powershell触发两次/三次

Azure函数应用程序powershell触发两次/三次,azure,powershell,azure-functions,Azure,Powershell,Azure Functions,我收到一个Azure警报,其中包含一个包含我的Azure功能应用程序的操作组 功能应用程序在消费计划中 但是,当触发1个警报时,我会收到两个,有时是三个功能应用程序回复。目前正在通过电子邮件进行测试,但可以是团队/Slack/Twilio或其他方式 我已经检查了我的代码好几次,但找不到它为什么运行了好几次。 这可能是冷启动问题吗? 我不应该点击超时,因为它会在几秒钟内完成 我需要下面的代码块吗 Push-OutputBinding -Name Response -Value ([HttpResp

我收到一个Azure警报,其中包含一个包含我的Azure功能应用程序的操作组
功能应用程序在消费计划中
但是,当触发1个警报时,我会收到两个,有时是三个功能应用程序回复。目前正在通过电子邮件进行测试,但可以是团队/Slack/Twilio或其他方式

我已经检查了我的代码好几次,但找不到它为什么运行了好几次。
这可能是冷启动问题吗?
我不应该点击超时,因为它会在几秒钟内完成
我需要下面的代码块吗

Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
    StatusCode = $status
})
例如,2019年11月14日上午4:59:02触发的警报
功能应用程序生成了三个回复:

  • 05:00
  • 05:00
  • 05:01

好的,在Azure支持的长期案例之后,这里有一个更新。如果有人到这里来

使用Azure应用程序功能的Azure警报操作组的核心是webhook调用。这意味着它具有与常规webhook相同的限制/约束。 看

10秒后重试,100秒后再次重试。如果在消费时使用Azure应用程序功能,应用程序功能冷启动可能需要更长的时间。这意味着它最多可以被调用三次,因为每次调用应用程序功能时,应用程序功能都会运行,即使冷启动功能需要时间(有时启动速度更快,您只能运行两次,如果它已经运行,您可以运行一次)

取决于你在做什么,这可能是个问题。Azure支持人员在中提出的建议以粗体显示,另一个是我可能的解决方案(请注意,我的建议将产生成本

  • 使函数幂等
  • 使函数有状态
  • 使用始终打开的应用程序服务计划
  • 使用逻辑应用程序
  • 如果Powershell使用自动化帐户运行手册

那么你的意思是你从警报中收到三封电子邮件?我可以知道您在创建函数应用程序时是否创建了application insight吗?如果是,您可以在application insight中查看有关该功能运行的更多信息。是的,我收到三封电子邮件,有时从警报中收到两封。我没有创建应用程序洞察,但我可以将其旋转起来用于故障排除目的。我可以知道您在“条件”中选择的信号您的警报?资源:日志分析工作区条件:信号类型:日志搜索信号名称:自定义日志搜索操作:具有Azure功能的操作组我们有一个功能应用程序,当app insights web测试失败时,它会向团队发送警报。自从他们升级了警报,我们也收到了2-3个警报。是的,我们升级了功能应用程序来处理新的有效负载格式。不确定为什么我们会收到多个警报,也没有仔细查看,但这可能不是您的代码的问题。
using namespace System.Net
using namespace System.Web

# Input bindings are passed in via param block.
param($Request) 
# Write to the Azure Functions log stream.
$alert = $Request.RawBody | convertfrom-json

function New-TypeTable([object[]]$columns)
{
    $hash = [ordered]@{}
    foreach ($c in $columns)
    {
        switch ($c.type)
        {
            "datetime" { $type = [datetime] }
            "real" { $type = [decimal] }
            default { $type = [string] }
        }
        $hash.Add($c.name, $type)
    }
    $hash
}

function Set-Culture([System.Globalization.CultureInfo] $culture)
{
    [System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
    [System.Threading.Thread]::CurrentThread.CurrentCulture = $culture
}

#Set locale to swedish for datetime
Set-Culture sv-SE
#Set variables for later use
$alertRule = $alert.data.essentials.alertRule
$alertDescription = $alert.data.essentials.description
$tables = $alert.data.alertContext.SearchResults.tables

foreach ($table in $tables)
{
    $cHash = New-TypeTable -columns $table.columns
    [string[]]$keys = $cHash.Keys
    $tableInfo = foreach ($row in $table.rows)
    {
        $psObj = New-Object PSObject
        for ($i = 0; $i -lt $row.Count; $i++)
        {
            $value = $row[$i]
            $type = $cHash[$i]
            #Round the value of AggregatedValue and CounterValue
            if ($keys[$i] -eq "AggregatedValue" -Or $keys[$i] -eq "CounterValue") {
                $value = [math]::Round($value,1)
            }
            #Set the value of TimeGenerated to a specific format
            if ($keys[$i] -eq "TimeGenerated") {
                $value = "{0:yyyy-MM-dd HH:mm:ss}" -f $value
            }
            #Don't add Null values
            if($value) {
                $psObj | Add-Member -MemberType NoteProperty -Name $keys[$i] -Value ($value -as $type)
            }
        }
        $psObj
    }
}
#Write-Information $tableInfo -verbose
$Header = @"
<style>
TABLE {width: 750px; border-width: 1px; border-style: solid; border-color: black; border-collapse: collapse;}
TH {border-width: 1px; padding: 3px; border-style: solid; border-color: black; background-color: #6495ED;}
TD {border-width: 1px; padding: 3px; border-style: solid; border-color: black;}
</style>
"@
#Create HTML-table from the object
$Body = $tableInfo | ConvertTo-Html -head $Header

DATE (UTC) SUCCESS RESULT CODE DURATION (MS) 
2019-11-18 20:31:16.092 204 799.4648 
2019-11-18 20:29:32.032 204 23197.282 
2019-11-18 20:29:17.956 204 41919.4075