azure - 来自 powershell 的事件网格函数 URL

标签 azure powershell azure-powershell

我有一个事件网格触发功能应用程序。我使用下面的代码来获取函数 URL。

function Get-Function-Key {
    return (Invoke-AzResourceAction `
            -Action listKeys `
            -ResourceType 'Microsoft.Web/sites/functions/' `
            -ResourceGroupName $ResourceGroup `
            -ResourceName "$FuncAppName/$FuncName" `
            -Force).default
}

$functionKey = Get-Function-Key -FuncAppName $FuncAppName -FuncName $FuncName `
                -ResourceGroup $ResourceGroup

$apiUrl = "https://$FuncAppName.azurewebsites.net/runtime/webhooks/EventGrid?functionName=$FuncName&code=$functionKey"

我注意到函数 URL 使用 masterkey 而不是函数键。 powershell中有没有命令可以获取函数URL的主 key 。

最佳答案

我在我这边测试了你的命令,它返回函数应用程序中EventGridTrigger的功能键。

所以如果你想获得主 key ,只需使用下面的命令即可。

function Get-Function-Key {
 param([string]$FuncAppName,[string]$ResourceGroup)
    return (Invoke-AzResourceAction `
            -Action listKeys `
            -ResourceType 'Microsoft.Web/sites/host/default' `
            -ResourceGroupName $ResourceGroup `
            -ResourceName "$FuncAppName" `
            -Force).masterKey
}

关于azure - 来自 powershell 的事件网格函数 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66598110/

相关文章:

powershell - 调用 New-AzureStorageTable cmdlet 时 VSTS 发布 Azure Powershell 任务失败

azure-service-fabric - Service Fabric 重启应用程序

azure - 使用 Rest API 创建 Azure BOT 时出现问题

正在使用的 Azure 应用服务部署文件

azure - 我从 Logic App 调用 MS-Graph 并收到 "Unauthorized"错误

azure - 无法删除 API 管理服务

powershell - 格式化Remove-Item命令的详细输出

windows - 我需要一个 powershell 脚本来监控正在运行的 Windows 计划任务超过 X 分钟

.net - 通过Telegram机器人发送sendDocument

azure - 如何通过 Azure Powershell 读取使用应用服务的应用服务计划的名称