Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    def test_function_app_dedicated(self):
        # provision storage account
        sa_params = {
            'name': 'custodianaccount47182741',
            '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 app plan
        app_plan_params = {
            'name': 'cloud-custodian-test2',
            'location': self.rg_location,
            'resource_group_name': self.rg_name,
            'sku_tier': 'Basic',
            'sku_name': 'B1'
        }
        app_plan_unit = AppServicePlanUnit()
        app_plan = app_plan_unit.provision(app_plan_params)

        # provision function app
        func_app_name = 'cc-dedicated-47182748'
        func_params = {
            'name': func_app_name,
            'location': self.rg_location,
            '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)