File tree 3 files changed +30
-1
lines changed
3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 6
6
import pyodbc
7
7
import socket
8
8
from 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
9
12
10
13
# Initialize Flask
11
14
app = Flask (__name__ )
12
15
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
+
13
23
# Setup Flask Restful framework
14
24
api = Api (app )
15
25
parser = reqparse .RequestParser ()
16
26
parser .add_argument ('customer' )
17
27
28
+ # Implement manual connection pooling
18
29
class ConnectionManager (object ):
19
30
__instance = None
20
31
__conn_index = 0
Original file line number Diff line number Diff line change @@ -30,6 +30,16 @@ az appservice plan create \
30
30
--sku B1 \
31
31
--is-linux
32
32
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
+
33
43
echo " Creating Web Application..." ;
34
44
az webapp create \
35
45
-g $resourceGroup \
@@ -45,3 +55,11 @@ az webapp config connection-string set \
45
55
-n $appName \
46
56
--settings WWIF=" $SQLAZURECONNSTR_WWIF " \
47
57
--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 1
1
pyodbc
2
2
flask
3
3
flask-restful
4
- applicationinsights
4
+ opencensus-ext-azure
You can’t perform that action at this time.
0 commit comments