noneNETHENTENTH,当我转到函数应用程序门户时,它在功能子菜单下没有显示任何内容:
按照@rithwikboj说明,我处于同样的情况。我已经观察到本地我都看不到这些功能:
这是我的
import azure.functions as func
import logging
import os
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
from azure.communication.email import EmailClient
from datetime import timezone, timedelta, datetime
import jwt
import bcrypt
import pymssql
import json
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@app.route(route="actualizar_contrasena", auth_level=func.AuthLevel.ANONYMOUS)
def actualizar_contrasena(req: func.HttpRequest) -> func.HttpResponse:
import json
try:
req_body = req.get_json()
username_to_check = req_body.get("username")
password_to_check = str(req_body.get("password"))
# do things
return func.HttpResponse(
json.dumps(
{"access_token": 1, "refresh_token": 1}
),
status_code=200,
)
except Exception as e:
return func.HttpResponse(str(e), status_code=500)
host.json
这是我的结构:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
这是我的要求。txt
root
|_.venv
|_.funcignore
|_host.json
|_function_app.py
|_ local.settings.json
i我意识到unignts.txt在函数应用中有问题
文件夹结构尚未更新,因为我一段时间以前删除了readme.md:
update
我已经编辑了YAML,现在它可以正确上传。
我使用了以下代码,它已为我部署,并遵循以下过程:
function_app.py:
import jwt
-local.settings.json:
import azure.functions as func
import logging as ri_lg
import pymssql as chop
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
rith = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@rith.route(
route="rith_func", methods=["POST"], auth_level=func.AuthLevel.ANONYMOUS
)
def rith_func(req: func.HttpRequest) -> func.HttpResponse:
try:
rith_rq_bdy = req.get_json()
eml = rith_rq_bdy.get("email")
pwd = rith_rq_bdy.get("password")
ri_con = chop.connect(server="rithwik.database.windows.net",user="rithwik",password="RTestpass@2",database="test1")
cho_cur = ri_con.cursor()
cho_cur.execute("UPDATE users SET password = %s WHERE email = %s",(pwd, eml))
ri_con.commit()
return func.HttpResponse("Hello Rithwik, the Password has been updated",status_code=200)
except Exception as f:
ri_lg.error(f"Error: {f}")
return func.HttpResponse(f"Hello Rithwik, there is an error: {f}",status_code=500)
finally:
if "ri_con" in locals() and ri_con:
ri_con.close()
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing"
}
}
-host.json:
azure-functions
pymssql
azure-identity
azure-keyvault-secrets
结构:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
输出:从VS代码中删除:
部署后:
然后用错误的数据进行了测试以获取500错误: