44from azure .mgmt .resource import ResourceManagementClient
55from azure .mgmt .storage import StorageManagementClient
66from azure .mgmt .web import WebSiteManagementClient
7- from zipfile import ZipFile
87import shutil
98
9+
1010def deploy_to_azure_functions (azure_credentials_json , azure_function_path ):
1111 """
1212 This function deploys a Python function app to Azure Functions.
1313
1414 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.
1719
1820 Returns:
1921 None
@@ -28,7 +30,6 @@ def deploy_to_azure_functions(azure_credentials_json, azure_function_path):
2830 LOCATION = "eastus"
2931 STORAGE_ACCOUNT_NAME = "mystorageaccount123"
3032 FUNCTION_APP_NAME = "my-python-function-app"
31- APP_SERVICE_PLAN_NAME = "myAppServicePlan"
3233
3334 # Authenticate using DefaultAzureCredential
3435 credential = DefaultAzureCredential ()
@@ -56,13 +57,22 @@ def deploy_to_azure_functions(azure_credentials_json, azure_function_path):
5657 # Create Function App (with a Consumption Plan)
5758 site_config = {
5859 "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}" ,
6064 "reserved" : True , # This is necessary for Linux-based function apps
6165 "site_config" : {
6266 "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+ }
6676 ]
6777 },
6878 "kind" : "functionapp" ,
0 commit comments