azure - Azure 函数应用程序的 listKeys

标签 azure azure-functions azure-cli

如何使用 listKeys ARM 函数列出 azure 函数应用的键?

我的模板:

 {
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {},
    "resources": [],
    "outputs": {
        "referenceOutput": {
            "type": "object",
            "value": "[listkeys(resourceId('Microsoft.Web/sites/functions', 'my-function-app','my-function'),'2016-08-01').key]"
        }
    }

然后运行:

az group deployment create -g my-rg --template-file ./arm.json --mode incremental

错误:

No route registered for '/api/functions/my-function/listkeys?api-version=2016-08-01'

最佳答案

尝试以下模板。

  "outputs": {
    "FunctionAppName": {
        "type": "string",
        "value": "[parameters('functionName')]"
    },
    "Key": {
        "type": "string",
        "value": "[listsecrets(resourceId('Microsoft.Web/sites/functions', parameters('existingFunctionAppName'), parameters('functionName')),'2015-08-01').key]"
    },        
    "Url": {
        "type": "string",
        "value": "[listsecrets(resourceId('Microsoft.Web/sites/functions', parameters('existingFunctionAppName'), parameters('functionName')),'2015-08-01').trigger_url]"
    }        
}

更多相关信息请引用此question .

您还可以使用Function App Api列出这个。

GET /admin/functions/{functionname}/keys

如果您使用 bash shell,则可以使用以下示例。

TENANT=""
CLIENT_ID=""
CLIENT_SECRET=""
SUBSCRIPTION_ID=""
RESOURCE_GROUP="shuiapp"
FUNCTION_APP_NAME="shuifunction"
API_URL="https://$FUNCTION_APP_NAME.scm.azurewebsites.net/api/functions/admin/token"
SITE_URL="https://$FUNCTION_APP_NAME.azurewebsites.net/admin/functions/HttpTriggerPowerShell1/keys"

### Grab a fresh bearer access token.
ACCESS_TOKEN=$(curl -s -X POST -F grant_type=client_credentials -F resource=https://management.azure.com/ -F client_id=$CLIENT_ID -F client_secret=$CLIENT_SECRET https://login.microsoftonline.com/$TENANT/oauth2/token | jq '.access_token' -r)

### Grab the publish data for the Funciton App and output it to an XML file.
PUBLISH_DATA=$(curl -s -X POST -H "Content-Length: 0" -H "Authorization: Bearer $ACCESS_TOKEN" https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.Web/sites/$FUNCTION_APP_NAME/publishxml?api-version=2016-08-01)
echo $PUBLISH_DATA > publish_data.xml

### Grab the Kudu username and password from the publish data XML file.
USER_NAME=$(xmlstarlet sel -t -v "//publishProfile[@profileName='$FUNCTION_APP_NAME - Web Deploy']/@userName" publish_data.xml)
USER_PASSWORD=$(xmlstarlet sel -t -v "//publishProfile[@profileName='$FUNCTION_APP_NAME - Web Deploy']/@userPWD" publish_data.xml)

### Generate a JWT that can be used with the Functions Key API.
JWT=$(curl -s -X GET -u $USER_NAME:$USER_PASSWORD $API_URL | tr -d '"')

### Grab the '_master' key from the Functions Key API.
KEY=$(curl -s -X GET -H "Authorization: Bearer $JWT" $SITE_URL | jq -r '.value')

关于azure - Azure 函数应用程序的 listKeys,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47985364/

相关文章:

azure - 如何使用 Kusto 访问 Azure Function 应用代码logging() 消息?

azure - 从 DevOps 管道中的服务主体生成 SAS token (自托管)

azure - 无法获取 https ://packages. microsoft.com/repos/azure-cli/dists/bionic/main/binary-amd64/Packages.gz 文件大小意外 (7772 != 7605)

Asp.net Azure WebApp发布网站但没有图片

c# - 如何将消息从 eventhub 发送到另一个 eventhub?

python - 如何验证向 Windows Azure 发出的管理服务请求?

Azure 未列出任何容器,但返回给定名称的信息

python - CNN 模型训练 - 资源耗尽(Python 和 Tensorflow)

java - (Azure SDK java)如何使用Java程序启用/禁用每个功能

azure - 如何在 Azure Function 中定义 Azure Blob 存储触发器的路径