首页 > 解决方案 > 尝试在 vscode 中执行 azure 函数

问题描述

我一直在尝试部署具有 azure 功能的烧瓶应用程序。它不工作。我是天蓝色的新手...

我的烧瓶应用程序是一个简单的计算器,我想在线使用 azure 函数。我的文件目录如下:

flaskapp
      |-flask application;
      |-index.html
azure_function:HTTP trigger function
      |-__init__.py
      |-function.json

这是我的初始化.py

def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse:

    return func.WsgiMiddleware(application).handle(req, context)

当我尝试在 vs 代码中本地调试我的函数时,我无法使其工作:找不到 404。当我执行函数时,我得到:执行函数“functionName”。回复:"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>404 Not Found</title> <h1>Not Found</h1> <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p> "

有人能帮助我吗?

标签: python-3.xvisual-studio-codeazure-functions

解决方案


这个问题需要更多细节。

404 Not found 错误总是意味着你错过了一些基本的东西。本地烧瓶应用程序的默认端口与本地的azure函数不同(azure函数为7071)。

并且 debug azure function 不仅仅意味着 debug __init__.py。其实就是调试整个函数应用(要实现这个,需要安装azure函数核心工具,VSCode的azure函数插件和语言调试插件)。


推荐阅读