def test_function_app_consumption(self): # provision storage account sa_params = { 'name': 'custodianaccount47182748', 'location': self.rg_location, 'resource_group_name': self.rg_name } storage_unit = StorageAccountUnit() storage_account_id = storage_unit.provision(sa_params).id conn_string = FunctionAppUtilities.get_storage_account_connection_string( storage_account_id) # provision function app func_params = { 'name': 'cc-consumption-47182748', # Using different location due to http://go.microsoft.com/fwlink/?LinkId=825764 'location': 'eastus2', 'resource_group_name': self.rg_name, 'app_service_plan_id': None, # auto-provision a dynamic app plan 'app_insights_key': None, 'is_consumption_plan': True, 'storage_account_connection_string': conn_string } func_unit = FunctionAppDeploymentUnit() func_app = self._validate(func_unit, func_params) # verify settings are properly configured self.assertEqual(func_app.kind, 'functionapp,linux') self.assertTrue(func_app.reserved)
def test_function_app_consumption(self): # provision storage account sa_params = { 'name': 'custodianaccount47182748', 'location': 'westus2', 'resource_group_name': self.rg_name} storage_unit = StorageAccountUnit() storage_account_id = storage_unit.provision_if_not_exists(sa_params).id conn_string = FunctionAppUtilities.get_storage_account_connection_string(storage_account_id) # provision function app func_params = { 'name': 'cc-consumption-47182748', 'location': 'westus', 'resource_group_name': self.rg_name, 'app_service_plan_id': None, # auto-provision a dynamic app plan 'app_insights_key': None, 'is_consumption_plan': True, 'storage_account_connection_string': conn_string } func_unit = FunctionAppDeploymentUnit() func_app = self._validate(func_unit, func_params) # verify settings are properly configured self.assertEqual(func_app.kind, 'functionapp,linux') self.assertTrue(func_app.reserved)
def test_get_storage_connection_string(self): storage_name = 'cloudcustodiantest' id = '/subscriptions/%s/resourceGroups/test_functionapp-reqs/providers/Microsoft.Storage' \ '/storageAccounts/cloudcustodiantest' % local_session(Session).subscription_id conn_string = FunctionAppUtilities.get_storage_account_connection_string( id) self.assertIn('AccountName=%s;' % storage_name, conn_string)
def test_function_app_dedicated(self): # provision storage account sa_params = { 'name': 'custodianaccount47182748', 'location': 'westus2', 'resource_group_name': self.rg_name } storage_unit = StorageAccountUnit() storage_account_id = storage_unit.provision_if_not_exists(sa_params).id conn_string = FunctionAppUtilities.get_storage_account_connection_string( storage_account_id) # provision app plan app_plan_params = { 'name': 'cloud-custodian-test', 'location': 'westus2', 'resource_group_name': self.rg_name, 'sku_tier': 'Basic', 'sku_name': 'B1' } app_plan_unit = AppServicePlanUnit() app_plan = app_plan_unit.provision_if_not_exists(app_plan_params) # provision function app func_app_name = 'cc-dedicated-47182748' func_params = { 'name': func_app_name, 'location': 'westus', 'resource_group_name': self.rg_name, 'app_service_plan_id': app_plan.id, 'app_insights_key': None, 'is_consumption_plan': False, 'storage_account_connection_string': conn_string } func_unit = FunctionAppDeploymentUnit() func_app = self._validate(func_unit, func_params) # verify settings are properly configured self.assertEquals(func_app.kind, 'functionapp,linux,container') self.assertTrue(func_app.reserved) wc = self.session.client('azure.mgmt.web.WebSiteManagementClient') site_config = wc.web_apps.get_configuration(self.rg_name, func_app_name) self.assertTrue(site_config.always_on) self.assertEquals(site_config.linux_fx_version, FUNCTION_DOCKER_VERSION) app_settings = wc.web_apps.list_application_settings( self.rg_name, func_app_name) self.assertIsNotNone( app_settings.properties['MACHINEKEY_DecryptionKey'])
def test_function_app_dedicated(self): # provision storage account sa_params = { 'name': 'custodianaccount47182748', 'location': 'westus2', 'resource_group_name': self.rg_name} storage_unit = StorageAccountUnit() storage_account_id = storage_unit.provision_if_not_exists(sa_params).id conn_string = FunctionAppUtilities.get_storage_account_connection_string(storage_account_id) # provision app plan app_plan_params = { 'name': 'cloud-custodian-test', 'location': 'westus2', 'resource_group_name': self.rg_name, 'sku_tier': 'Basic', 'sku_name': 'B1'} app_plan_unit = AppServicePlanUnit() app_plan = app_plan_unit.provision_if_not_exists(app_plan_params) # provision function app func_app_name = 'cc-dedicated-47182748' func_params = { 'name': func_app_name, 'location': 'westus', 'resource_group_name': self.rg_name, 'app_service_plan_id': app_plan.id, 'app_insights_key': None, 'is_consumption_plan': False, 'storage_account_connection_string': conn_string } func_unit = FunctionAppDeploymentUnit() func_app = self._validate(func_unit, func_params) # verify settings are properly configured self.assertEqual(func_app.kind, 'functionapp,linux,container') self.assertTrue(func_app.reserved) wc = self.session.client('azure.mgmt.web.WebSiteManagementClient') site_config = wc.web_apps.get_configuration(self.rg_name, func_app_name) self.assertTrue(site_config.always_on) self.assertEqual(site_config.linux_fx_version, FUNCTION_DOCKER_VERSION) app_settings = wc.web_apps.list_application_settings(self.rg_name, func_app_name) self.assertIsNotNone(app_settings.properties['MACHINEKEY_DecryptionKey'])
def test_get_storage_connection_string(self): id = '/subscriptions/%s/resourceGroups/test_functionapp-reqs/providers/Microsoft.Storage' \ '/storageAccounts/%s' % (self.subscription_id, self.storage_name) conn_string = FunctionAppUtilities.get_storage_account_connection_string( id) self.assertIn('AccountName=%s;' % self.storage_name, conn_string)
def test_get_storage_connection_string(self): storage_name = 'cloudcustodiantest' id = '/subscriptions/%s/resourceGroups/test_functionapp-reqs/providers/Microsoft.Storage' \ '/storageAccounts/cloudcustodiantest' % local_session(Session).subscription_id conn_string = FunctionAppUtilities.get_storage_account_connection_string(id) self.assertIn('AccountName=%s;' % storage_name, conn_string)