2017-12-27 23 views
0

listKeys ARM 함수를 사용하여 하늘색 함수의 키를 어떻게 나열합니까?목록 Azure 함수 appKeys

내 템플릿 :

{ 
    "$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' 

답변

1

보십시오. 이것에 대해

"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 쉘을 사용하는 경우 다음 예제를 사용할 수 있습니다.

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') 
+0

bash 쉘 스크립트를 사용하는 경우 먼저'jq'와'xmlstarlet'을 먼저 설치해야합니다. 'apt install jq''apt install xmlstarlet' –

+0

죄송합니다. 테스트 템플릿이 아니므로 리눅스 스크립트를 테스트 해보십시오. 희망이 도움이됩니다. –

+0

감사합니다. 문제는 listSecrets가 아닌 listKeys를 사용한다는 것이 었습니다. –