File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 66import pyodbc
77import socket
88from threading import Lock
9+ from opencensus .ext .azure .trace_exporter import AzureExporter
10+ from opencensus .ext .flask .flask_middleware import FlaskMiddleware
11+ from opencensus .trace .samplers import ProbabilitySampler
912
1013# Initialize Flask
1114app = Flask (__name__ )
1215
16+ # Setup Azure Monitor
17+ middleware = FlaskMiddleware (
18+ app ,
19+ exporter = AzureExporter (connection_string = "InstrumentationKey={0}" .format (os .environ ['APPINSIGHTS_KEY' ])),
20+ sampler = ProbabilitySampler (rate = 1.0 ),
21+ )
22+
1323# Setup Flask Restful framework
1424api = Api (app )
1525parser = reqparse .RequestParser ()
1626parser .add_argument ('customer' )
1727
28+ # Implement manual connection pooling
1829class ConnectionManager (object ):
1930 __instance = None
2031 __conn_index = 0
Original file line number Diff line number Diff line change @@ -30,6 +30,16 @@ az appservice plan create \
3030 --sku B1 \
3131 --is-linux
3232
33+ echo " Creating Application Insight..."
34+ az resource create \
35+ -g $resourceGroup \
36+ -n $appName -ai \
37+ --resource-type " Microsoft.Insights/components" \
38+ --properties ' {"Application_Type":"web"}'
39+
40+ echo " Reading Application Insight Key..."
41+ aikey=` az resource show -g $resourceGroup -n $appName -ai --resource-type " Microsoft.Insights/components" --query properties.InstrumentationKey -o tsv`
42+
3343echo " Creating Web Application..." ;
3444az webapp create \
3545 -g $resourceGroup \
@@ -45,3 +55,11 @@ az webapp config connection-string set \
4555 -n $appName \
4656 --settings WWIF=" $SQLAZURECONNSTR_WWIF " \
4757 --connection-string-type=SQLAzure
58+
59+ echo " Configuring Application Insights..." ;
60+ az webapp config appsettings set \
61+ -g $resourceGroup \
62+ -n $appName \
63+ --settings APPINSIGHTS_KEY=" $aikey "
64+
65+ echo " Done."
Original file line number Diff line number Diff line change 11pyodbc
22flask
33flask-restful
4- applicationinsights
4+ opencensus-ext-azure
You can’t perform that action at this time.
0 commit comments