@@ -363,6 +363,89 @@ After creating the function app, please contact EDAV team and request permission
363363- Debugging the function app in Azure requires specific permissions. Currently, debugging is not supported directly. Users may need to work with the EDAV team for additional access if needed.
364364- Currently the Azure Function Manager can only be invoked from a Linux environment such as Bash shell, Git Bash or Windows Subsystem for Linux. In a future release, support shall be added for Windows Command prompt.
365365
366+ ## 6. Scripts for getting metadata about exising Azure Function App
367+
368+ After successfully deploying a function app, you can use one of the following class methods on ` FunctionAppClient ` to retrieve configuration and runtime details about the function app. All these class methods expect Azure resource group and subscription ID to be provided. There are 2 ways of setting this up:
369+
370+ * set the ` AZURE_RESOURCE_GROUP ` and ` AZURE_SUBSCRIPTION_ID ` environment variables, or
371+ * set the ` resource_group ` and ` subscription_id ` method parameters on each invocation
372+
373+ #### get_configuration
374+
375+ Retrieves the configuration details an app, such as platform version, runtime environment, handler mappings, IP security restrictions, default documents, virtual applications, Always On, etc.
376+
377+ _ Example_ :
378+ ``` python
379+ from cfa.cloudops import FunctionAppClient
380+ FunctionAppClient.get_configuration(function_app_name = ' cfapredictafmprdfunc03' )
381+ ```
382+
383+ _ Response_ :
384+ ``` json
385+ {'additional_properties': {'location': 'East US', 'tags': {'center': 'cfa', 'dateCreated': '2024-07-25 00:00:00', 'division': 'none', 'environment': 'prd', 'project': 'afm', 'requestor': ' ure7@cdc.gov', 'Purpose': 'Run Scheduled Job', 'costid': 'cfa', 'resourcename': 'cfapredictafmprdfunc03', 'issharedresource': 'no', 'owner': 'edav', 'createdby': 'none'}}, 'id': '/subscriptions/ef340bd6-2809-4635-b18b-7e6583a8803b/resourceGroups/EXT-EDAV-CFA-PRD/providers/Microsoft.Web/sites/cfapredictafmprdfunc03/config/web', 'name': 'cfapredictafmprdfunc03', 'kind': None, 'type': 'Microsoft.Web/sites/config', 'number_of_workers': 1, 'default_documents': ['Default.htm', 'Default.html', 'Default.asp', 'index.htm', 'index.html', 'iisstart.htm', 'default.aspx', 'index.php'], 'net_framework_version': 'v4.0', 'php_version': '', 'python_version': '', 'node_version': '', 'power_shell_version': '', 'linux_fx_version': 'PYTHON|3.9', 'windows_fx_version': None, 'request_tracing_enabled': False, 'request_tracing_expiration_time': None, 'remote_debugging_enabled': False, 'remote_debugging_version': None, 'http_logging_enabled': False, 'acr_use_managed_identity_creds': False, 'acr_user_managed_identity_id': None, 'logs_directory_size_limit': 35, 'detailed_error_logging_enabled': False, 'publishing_username': '$cfapredictafmprdfunc03', 'app_settings': None, 'metadata': None, 'connection_strings': None, 'machine_key': None, 'handler_mappings': None, 'document_root': None, 'scm_type': 'None', 'use32_bit_worker_process': False, 'web_sockets_enabled': False, 'always_on': True, 'java_version': None, 'java_container': None, 'java_container_version': None, 'app_command_line': '', 'managed_pipeline_mode': 'Integrated', 'virtual_applications': [<azure.mgmt.web.models._models_py3.VirtualApplication object at 0x789ab99aee00>], 'load_balancing': 'LeastRequests', 'experiments': <azure.mgmt.web.models._models_py3.Experiments object at 0x789ab99ac340>, 'limits': None, 'auto_heal_enabled': False, 'auto_heal_rules': None, 'tracing_options': None, 'vnet_name': '', 'vnet_route_all_enabled': False, 'vnet_private_ports_count': 0, 'cors': <azure.mgmt.web.models._models_py3.CorsSettings object at 0x789ab99ac5e0>, 'push': None, 'api_definition': None, 'api_management_config': None, 'auto_swap_slot_name': None, 'local_my_sql_enabled': False, 'managed_service_identity_id': None, 'x_managed_service_identity_id': None, 'key_vault_reference_identity': None, 'ip_security_restrictions': [<azure.mgmt.web.models._models_py3.IpSecurityRestriction object at 0x789ab99acfd0>], 'ip_security_restrictions_default_action': 'Allow', 'scm_ip_security_restrictions': [<azure.mgmt.web.models._models_py3.IpSecurityRestriction object at 0x789ab99aebc0>], 'scm_ip_security_restrictions_default_action': 'Allow', 'scm_ip_security_restrictions_use_main': False, 'http20_enabled': False, 'http20_proxy_flag': 0, 'min_tls_version': '1.2', 'min_tls_cipher_suite': None, 'scm_min_tls_version': '1.2', 'ftps_state': 'Disabled', 'pre_warmed_instance_count': 0, 'function_app_scale_limit': 0, 'elastic_web_app_scale_limit': None, 'health_check_path': '/api/HealthCheck', 'functions_runtime_scale_monitoring_enabled': False, 'website_time_zone': None, 'minimum_elastic_instance_count': 1, 'azure_storage_accounts': {}, 'public_network_access': 'Enabled'}
386+ {'location': 'East US', 'tags': {'center': 'cfa', 'dateCreated': '2024-07-25 00:00:00', 'division': 'none', 'environment': 'prd', 'project': 'afm', 'requestor': ' ure7@cdc.gov', 'Purpose': 'Run Scheduled Job', 'costid': 'cfa', 'resourcename': 'cfapredictafmprdfunc03', 'issharedresource': 'no', 'owner': 'edav', 'createdby': 'none' }}
387+ ```
388+
389+ #### get_function_details
390+
391+ Fetch details of specific function within a function app. You can invoke the ` list_functions ` method to obtain list of function names from the function app.
392+
393+ _ Example_ :
394+ ``` python
395+ from cfa.cloudops import FunctionAppClient
396+ FunctionAppClient.get_function_details(function_app_name = ' cfapredictafmprdfunc03' , function_name = ' cfatimer' )
397+ ```
398+
399+ _ Response_ :
400+ ``` json
401+ {'additional_properties': {'location': 'East US'}, 'id': '/subscriptions/ef340bd6-2809-4635-b18b-7e6583a8803b/resourceGroups/EXT-EDAV-CFA-PRD/providers/Microsoft.Web/sites/cfapredictafmprdfunc03/functions/cfatimer', 'name': 'cfapredictafmprdfunc03/cfatimer', 'kind': None, 'type': 'Microsoft.Web/sites/functions', 'function_app_id': None, 'script_root_path_href': None, 'script_href': 'https://cfapredictafmprdfunc03.cfa-prd-app.appserviceenvironment.net/admin/vfs/home/site/wwwroot/function_app.py', 'config_href': None, 'test_data_href': 'https://cfapredictafmprdfunc03.cfa-prd-app.appserviceenvironment.net/admin/vfs/home/data/Functions/sampledata/cfatimer.dat', 'secrets_file_href': None, 'href': 'https://cfapredictafmprdfunc03.cfa-prd-app.appserviceenvironment.net/admin/functions/cfatimer', 'config': {'name': 'cfatimer', 'entryPoint': 'cfatimer', 'scriptFile': 'function_app.py', 'language': 'python', 'functionDirectory': '/home/site/wwwroot', 'bindings': [{'direction': 'IN', 'type': 'timerTrigger', 'name': 'cfatimer', 'schedule': '%CFANotificationV2CRON%', 'runOnStartup': False, 'useMonitor': True}]}, 'files': None, 'test_data': '', 'invoke_url_template': None, 'language': 'python', 'is_disabled': False}
402+ ```
403+
404+ #### get_health_check_flag
405+
406+ Retrieves the current status (True or False) of health check enabled on a function app.
407+
408+ _ Example_ :
409+ ``` python
410+ from cfa.cloudops import FunctionAppClient
411+ FunctionAppClient.get_health_check_flag(function_app_name = ' cfapredictafmprdfunc03' )
412+ ```
413+
414+ _ Response_ :
415+ ``` text
416+ True
417+ ```
418+
419+ #### get_tags
420+
421+ Retrieves the tags assigned to an app. This is a subset of the response returned from ` get_configuration ` method.
422+
423+ _ Example_ :
424+ ``` python
425+ from cfa.cloudops import FunctionAppClient
426+ FunctionAppClient.get_tags(function_app_name = ' cfapredictafmprdfunc03' )
427+ ```
428+
429+ _ Response_ :
430+ ``` json
431+ {'location': 'East US', 'tags': {'center': 'cfa', 'dateCreated': '2024-07-25 00:00:00', 'division': 'none', 'environment': 'prd', 'project': 'afm', 'requestor': ' ure7@cdc.gov', 'Purpose': 'Run Scheduled Job', 'costid': 'cfa', 'resourcename': 'cfapredictafmprdfunc03', 'issharedresource': 'no', 'owner': 'edav', 'createdby': 'none' }}
432+ ```
433+
434+ #### list_functions
435+
436+ Retrieves list of all functions packaged and deployed to the specified function app.
437+
438+ _ Example_ :
439+ ``` python
440+ from cfa.cloudops import FunctionAppClient
441+ FunctionAppClient.list_functions(function_app_name = ' cfapredictafmprdfunc03' )
442+ ```
443+
444+ _ Response_ :
445+ ``` json
446+ [{'id': '/subscriptions/ef340bd6-2809-4635-b18b-7e6583a8803b/resourceGroups/EXT-EDAV-CFA-PRD/providers/Microsoft.Web/sites/cfapredictafmprdfunc03/functions/cfatimer', 'name': 'cfapredictafmprdfunc03/cfatimer', 'type': 'Microsoft.Web/sites/functions', 'script_href': 'https://cfapredictafmprdfunc03.cfa-prd-app.appserviceenvironment.net/admin/vfs/home/site/wwwroot/function_app.py', 'test_data_href': 'https://cfapredictafmprdfunc03.cfa-prd-app.appserviceenvironment.net/admin/vfs/home/data/Functions/sampledata/cfatimer.dat', 'href': 'https://cfapredictafmprdfunc03.cfa-prd-app.appserviceenvironment.net/admin/functions/cfatimer', 'config': {'name': 'cfatimer', 'entryPoint': 'cfatimer', 'scriptFile': 'function_app.py', 'language': 'python', 'functionDirectory': '/home/site/wwwroot', 'bindings': [{'direction': 'IN', 'type': 'timerTrigger', 'name': 'cfatimer', 'schedule': '%CFANotificationV2CRON%', 'runOnStartup': False, 'useMonitor': True}]}, 'test_data': '', 'language': 'python', 'is_disabled': False}, {'id': '/subscriptions/ef340bd6-2809-4635-b18b-7e6583a8803b/resourceGroups/EXT-EDAV-CFA-PRD/providers/Microsoft.Web/sites/cfapredictafmprdfunc03/functions/HealthCheck', 'name': 'cfapredictafmprdfunc03/HealthCheck', 'type': 'Microsoft.Web/sites/functions', 'script_href': 'https://cfapredictafmprdfunc03.cfa-prd-app.appserviceenvironment.net/admin/vfs/home/site/wwwroot/function_app.py', 'test_data_href': 'https://cfapredictafmprdfunc03.cfa-prd-app.appserviceenvironment.net/admin/vfs/home/data/Functions/sampledata/HealthCheck.dat', 'href': 'https://cfapredictafmprdfunc03.cfa-prd-app.appserviceenvironment.net/admin/functions/HealthCheck', 'config': {'name': 'HealthCheck', 'entryPoint': 'HealthCheck', 'scriptFile': 'function_app.py', 'language': 'python', 'functionDirectory': '/home/site/wwwroot', 'bindings': [{'direction': 'IN', 'type': 'httpTrigger', 'name': 'req', 'authLevel': 'ANONYMOUS', 'route': 'HealthCheck'}, {'direction': 'OUT', 'type': 'http', 'name': '$return'}]}, 'test_data': '', 'invoke_url_template': 'https://cfapredictafmprdfunc03.cfa-prd-app.appserviceenvironment.net/api/healthcheck', 'language': 'python', 'is_disabled': False}]
447+ ```
448+
366449### Conclusion
367450By following this guide, you should be able to set up and use the CFA Azure Function test effectively. Ensure that all environment variables are correctly set and that your Service Principal has the necessary permissions.
368451
0 commit comments