简体   繁体   中英

Running dash app in azure functions python model v2 but only getting default site up page

I'm using the v2 python programming model and trying to launch a dash app similar to the example of a Flask app here

my function_app.py is as follows:

import dash
from dash import dcc
from dash import html
import azure.functions as func

dashapp = dash.Dash()
colors = {
    'background': '#111111',
    'text': '#7FDBFF'
}
dashapp.layout = html.Div(
    style={'backgroundColor': colors['background']}, 
        children=[
            html.H1(
                children='Hello Dash',
                style={
                    'textAlign': 'center',
                    'color': colors['text']
                }
            ),
            html.Div(children='Dash: A web application framework for Python.', style={
                'textAlign': 'center',
                'color': colors['text']
            }),
            dcc.Graph(
                id='Graph1',
                figure={
                    'data': [
                        {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
                        {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
                    ],
                    'layout': {
                        'plot_bgcolor': colors['background'],
                        'paper_bgcolor': colors['background'],
                        'font': {
                            'color': colors['text']
                        }
                    }
                }
            )
    ]
    )

app = func.WsgiFunctionApp(app=dashapp.server.wsgi_app, 
                        http_auth_level=func.AuthLevel.ANONYMOUS)

My host.json is:

{
"version": "2.0",
"logging": {
    "applicationInsights": {
    "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
    }
    }
},
"extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[3.15.0, 4.0.0)"
},
"functionTimeout": "00:10:00",
"extensions": 
{
    "http": 
    {
        "routePrefix": ""
    }
}
}

When I run locally it works as expected with my app at http://localhost:7072/ but when I deploy to Azure functions and go to myapp.azurewebsites.net then I just get the your app is up and running page. My guess is that Azure is serving that at the root address regardless of my app but the local deployment doesn't but I don't know how to verify that or, more importantly, change that behavior.

As @ vrdmr and @ MughundhanRaveendran-MSFT suggested that the base URL of Azure Functions states that the Function is in Running State in the MS Q&A # 1161595

  • Whatever the Language Runtime APIs we are deploying/publishing to Azure Functions, that Function API Name should be suffixed with the Azure Function base URL.
  • It can be local host Function URL or published Azure Function URL, Function API name is suffixed with the base address.
  • For the Local host Azure Functions Running, the format will be (localhost + Port + Function API Name (Http Context based trigger) and (Azure base function URL + Function API name + Authorization key-value if Authorization is defined such as Anonymous, Function or Admin or Custom)

在此处输入图像描述

  • Also, Make Sure a new application setting is added to the Python V2 model in Azure Function App in the Portal Menu, will be available by default in the local Project local.settings.json ie, AzureWebJobsFeatureFlags:EnableWorkerIndexing .

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM