Untitled
import csv import subprocess function_app_name = "YourFunctionAppName" resource_group_name = "YourResourceGroupName" csv_file_path = "path/to/your/file.csv" base_command = ["az", "functionapp", "config", "appsettings", "set", "--name", function_app_name, "--resource-group", resource_group_name, "--settings"] settings = [] with open(csv_file_path, mode='r', newline='') as csv_file: csv_reader = csv.reader(csv_file) for row in csv_reader: if row: # Check if row is not empty key, value = row settings.append(f"{key}={value}") if settings: try: subprocess.run(base_command + settings, check=True) print("Environment variables updated successfully.") except subprocess.CalledProcessError as e: print("Failed to update environment variables. Error:", e) else: print("No settings found in CSV file.")
Leave a Comment