I have successfully integrated a secret in a httptrigger. I need to retrieve and parse the secret in a python code.
The following piece of code returns the vault id and not the secret.
- How do I get it to output a secret values?
- Can the same be done for a queuetrigger?
Httptrigger
import logging
import os
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
test = os.environ["testkeyvault"]
return func.HttpResponse(
"This" + test,
status_code=200
)
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python",
"testkeyvault": "@Microsoft.KeyVault(SecretUri=https://jjjjj.vault.azure.net/secrets/AzureAuthUrl/xxxxxx)"
}
}
function.json
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}