4
4
from azure .mgmt .resource import ResourceManagementClient
5
5
from azure .mgmt .storage import StorageManagementClient
6
6
from azure .mgmt .web import WebSiteManagementClient
7
- from zipfile import ZipFile
8
7
import shutil
9
8
9
+
10
10
def deploy_to_azure_functions (azure_credentials_json , azure_function_path ):
11
11
"""
12
12
This function deploys a Python function app to Azure Functions.
13
13
14
14
Parameters:
15
- - azure_credentials_json (str): Path to the Azure credentials JSON file.
16
- - azure_function_path (str): Path to the Python function app directory.
15
+ - azure_credentials_json (str): Path to the Azure credentials
16
+ JSON file.
17
+ - azure_function_path (str): Path to the Python function
18
+ app directory.
17
19
18
20
Returns:
19
21
None
@@ -28,7 +30,6 @@ def deploy_to_azure_functions(azure_credentials_json, azure_function_path):
28
30
LOCATION = "eastus"
29
31
STORAGE_ACCOUNT_NAME = "mystorageaccount123"
30
32
FUNCTION_APP_NAME = "my-python-function-app"
31
- APP_SERVICE_PLAN_NAME = "myAppServicePlan"
32
33
33
34
# Authenticate using DefaultAzureCredential
34
35
credential = DefaultAzureCredential ()
@@ -56,13 +57,22 @@ def deploy_to_azure_functions(azure_credentials_json, azure_function_path):
56
57
# Create Function App (with a Consumption Plan)
57
58
site_config = {
58
59
"location" : LOCATION ,
59
- "server_farm_id" : f"/subscriptions/{ SUBSCRIPTION_ID } /resourceGroups/{ RESOURCE_GROUP_NAME } /providers/Microsoft.Web/serverfarms/{ APP_SERVICE_PLAN_NAME } " ,
60
+ "server_farm_id" : f"/subscriptions/{ SUBSCRIPTION_ID } " +
61
+ "/resourceGroups" +
62
+ "/{RESOURCE_GROUP_NAME}/providers/Microsoft.Web/" +
63
+ "serverfarms/{APP_SERVICE_PLAN_NAME}" ,
60
64
"reserved" : True , # This is necessary for Linux-based function apps
61
65
"site_config" : {
62
66
"app_settings" : [
63
- {"name" : "FUNCTIONS_WORKER_RUNTIME" , "value" : "python" },
64
- {"name" : "AzureWebJobsStorage" ,
65
- "value" : f"DefaultEndpointsProtocol=https;AccountName={ STORAGE_ACCOUNT_NAME } ;AccountKey=<account_key>" },
67
+ {
68
+ "name" : "FUNCTIONS_WORKER_RUNTIME" , "value" : "python"
69
+ },
70
+ {
71
+ "name" : "AzureWebJobsStorage" ,
72
+ "value" : "DefaultEndpointsProtocol=https;" + \
73
+ f"AccountName={ STORAGE_ACCOUNT_NAME } " + \
74
+ ";AccountKey=account_key>" ,
75
+ }
66
76
]
67
77
},
68
78
"kind" : "functionapp" ,
0 commit comments