def destroy(rg): client = AzureClient.new_instance(rg.subscription) print "Destroying resource group [%s]" % rg.resourceName found = client.destroy_resource_group(rg.resourceName) if not found: print "Resource group was not found. Destroy operation ignored." print "Done"
def setUpClass(self): rg = ResourceGroupCi() self.resource_group = rg.resourceName self.client = AzureClient.new_instance(rg.subscription) webjob_ci = TriggeredWebJobCi() webjob_ci.container = rg webjob_ci.file = File(Thread.currentThread().getContextClassLoader().getResource("webjob.zip").toURI()) continuous_webjob_ci = ContinuousWebJobCi() continuous_webjob_ci.container = rg continuous_webjob_ci.file = File(Thread.currentThread().getContextClassLoader().getResource("continuous_webjob.zip").toURI()) webapp_ci = WebAppCi() webapp_ci.appSettings = {} webapp_ci.customConnectionStrings = {} webapp_ci.sqlServerConnectionStrings = {} webapp_ci.sqlDatabaseConnectionStrings = {} self.client.create_resource_group(rg.resourceName, rg.resourceLocation) define_app_service_plan.create_or_update(AppServicePlanCi(), rg) define_web_app.create_or_update(webapp_ci, rg) self.client.wait_for_kudu_services(webjob_ci.appName) self.webjob = webjob_ci.webJobName self.site_name = webjob_ci.appName self.webjob_ci = webjob_ci self.continuous_webjob_ci = continuous_webjob_ci self.continuous_webjob = continuous_webjob_ci.webJobName
def destroy(deployed, container): client = AzureClient.new_instance(container.subscription) print "Destroying app service plan [%s] from resource group [%s]" % (deployed.servicePlanName, container.resourceName) found = client.destroy_app_service_plan(container.resourceName, deployed.servicePlanName) if not found: print "App service plan was not found. Destroy operation ignored." print "Done"
def test_discovery(self): self.client = AzureClient.new_instance(self.subscription) inspect.perform_discovery(self.subscription, self.inspection_ctx, self.descriptor, self.descriptor, self.descriptor) for ci in self.inspection_ctx.cis: print ci.__dict__
def create_or_update(deployed, container): client = AzureClient.new_instance(container.subscription) print "Defining web site [%s] in resource group [%s]" % ( deployed.appName, container.resourceName) client.create_website(container.resourceName, deployed.appName, container.resourceLocation, deployed.plan) print "Updating general settings" client.update_general_settings(container.resourceName, deployed.appName, container.resourceLocation, to_general_settings(deployed)) if deployed.appSettings.keys(): print "Updating app settings" client.update_app_settings(container.resourceName, deployed.appName, container.resourceLocation, deployed.appSettings) if deployed.sqlDatabaseConnectionStrings.keys( ) or deployed.sqlServerConnectionStrings.keys( ) or deployed.customConnectionStrings.keys(): print "Updating connection strings" client.update_db_conn_settings(container.resourceName, deployed.appName, container.resourceLocation, deployed.sqlDatabaseConnectionStrings, deployed.sqlServerConnectionStrings, deployed.customConnectionStrings) print "Done"
def destroy(deployed, container): client = AzureClient.new_instance(container.subscription) print "Destroying web site [%s] from resource group [%s]" % (deployed.appName, container.resourceName) found = client.destroy_website(container.resourceName, deployed.appName) if not found: print "Web site was not found. Destroy operation ignored." print "Done"
def create_or_update(rg): client = AzureClient.new_instance(rg.subscription) print "Defining resource group [%s] in location [%s]" % ( rg.resourceName, rg.resourceLocation) client.create_resource_group(rg.resourceName, rg.resourceLocation, rg.resourceTags) print "Done"
def upload(deployed, container): client = AzureClient.new_instance(container.subscription) retry_count = 0 available = False while retry_count < 12: print "Checking if Azure ftp upload service available for web site [%s]" % deployed.appName rc = client.is_kudu_services_available(deployed.appName) if rc == 0: available = True break retry_count += 1 print "Failed to connect to Azure ftp upload service (rc=%s). Will retry in 5 seconds. Attempt %s" % ( rc, retry_count) time.sleep(5) if not available: print "Failed to connect to Azure ftp upload service after 12 attempts. Retry in a while." sys.exit(1) print "Stopping website if already running. This to prevent file locking." client.stop_website(container.resourceName, deployed.appName) print "Uploading web site [%s] in resource group [%s]" % ( deployed.appName, container.resourceName) client.upload_website(deployed.appName, deployed.file.path) print "Done"
def upload(deployed, container): client = AzureClient.new_instance(container.subscription) retry_count = 0 available = False while retry_count < 12: print "Checking if Azure ftp upload service available for web site [%s]" % deployed.appName rc = client.is_kudu_services_available(deployed.appName) if rc == 0: available = True break retry_count += 1 print "Failed to connect to Azure ftp upload service (rc=%s). Will retry in 5 seconds. Attempt %s" % (rc, retry_count) time.sleep(5) if not available: print "Failed to connect to Azure ftp upload service after 12 attempts. Retry in a while." sys.exit(1) print "Stopping website if already running. This to prevent file locking." client.stop_website(container.resourceName, deployed.appName) print "Uploading web site [%s] in resource group [%s]" % (deployed.appName, container.resourceName) client.upload_website(deployed.appName, deployed.file.path) print "Done"
def setUpClass(self): self.resource_group_ci = ResourceGroupCi() self.app_service_plan_ci = AppServicePlanCi() self.expected_name = self.app_service_plan_ci.servicePlanName self.app_service_plan_ci.container = self.resource_group_ci self.expected_rg = self.resource_group_ci.resourceName self.client = AzureClient.new_instance(self.resource_group_ci.subscription) self.client.create_resource_group(self.resource_group_ci.resourceName, self.resource_group_ci.resourceLocation)
def create_or_update(deployed, container): client = AzureClient.new_instance(container.subscription) print "Checking for web application [%s]" % deployed.appName if not client.website_exists(container.resourceName, deployed.appName): raise Exception("Web application [%s] in resource group [%s] not found" % (deployed.appName, container.resourceName)) print "Deploying continuous web job [%s] to web app [%s] in resource group [%s]" % (deployed.webJobName, deployed.appName, container.resourceName) client.deploy_continuous_webjob(deployed.webJobName, deployed.appName, deployed.executableFileName, deployed.isSingleton, deployed.file.path) print "Done"
def create_or_update(deployed, container): client = AzureClient.new_instance(container.subscription) print "Defining app service plan [%s] in resource group [%s]" % ( deployed.servicePlanName, container.resourceName) client.create_app_service_plan(container.resourceName, deployed.servicePlanName, deployed.location, deployed.sku, deployed.workerSize) print "Done"
def destroy(deployed, container): client = AzureClient.new_instance(container.subscription) print "Destroying app service plan [%s] from resource group [%s]" % ( deployed.servicePlanName, container.resourceName) found = client.destroy_app_service_plan(container.resourceName, deployed.servicePlanName) if not found: print "App service plan was not found. Destroy operation ignored." print "Done"
def setUpClass(self): self.resource_group_ci = ResourceGroupCi() self.app_service_plan_ci = AppServicePlanCi() self.expected_name = self.app_service_plan_ci.servicePlanName self.app_service_plan_ci.container = self.resource_group_ci self.expected_rg = self.resource_group_ci.resourceName self.client = AzureClient.new_instance( self.resource_group_ci.subscription) self.client.create_resource_group( self.resource_group_ci.resourceName, self.resource_group_ci.resourceLocation)
def destroy(deployed, container): client = AzureClient.new_instance(container.subscription) print "Checking for web application [%s]" % deployed.appName if not client.website_exists(container.resourceName, deployed.appName): print "Web application [%s] in resource group [%s] not found" % (deployed.appName, container.resourceName) print "Will not attempt to delete web job as it would have been destroyed with web app" return print "Deleting continuous web job [%s] from web app [%s] in resource group [%s]" % (deployed.webJobName, deployed.appName, container.resourceName) client.remove_continuous_webjob(deployed.webJobName, deployed.appName) print "Done"
def create_or_update(deployed, container): client = AzureClient.new_instance(container.subscription) print "Checking for web application [%s]" % deployed.appName if not client.website_exists(container.resourceName, deployed.appName): raise Exception( "Web application [%s] in resource group [%s] not found" % (deployed.appName, container.resourceName)) print "Deploying triggered web job [%s] to web app [%s] in resource group [%s]" % ( deployed.webJobName, deployed.appName, container.resourceName) client.deploy_triggered_webjob(deployed.webJobName, deployed.appName, deployed.executableFileName, deployed.schedule, deployed.file.path) print "Done"
def setUpClass(self): rg = ResourceGroupCi() self.resource_group = rg.resourceName self.client = AzureClient.new_instance(rg.subscription) plan = AppServicePlanCi() plan.container = rg self.web_app_ci = WebAppCi() self.web_app_ci.container = rg self.site_name = self.web_app_ci.appName web_site_zip = File(Thread.currentThread().getContextClassLoader().getResource("web_site.zip").toURI()) self.web_app_ci.file = web_site_zip self.client.create_resource_group(rg.resourceName, rg.resourceLocation) define_app_service_plan.create_or_update(plan, rg)
def setUpClass(self): rg = ResourceGroupCi() self.resource_group = rg.resourceName self.client = AzureClient.new_instance(rg.subscription) plan = AppServicePlanCi() plan.container = rg self.web_app_ci = WebAppCi() self.web_app_ci.container = rg self.site_name = self.web_app_ci.appName web_site_zip = File( Thread.currentThread().getContextClassLoader().getResource( "web_site.zip").toURI()) self.web_app_ci.file = web_site_zip self.client.create_resource_group(rg.resourceName, rg.resourceLocation) define_app_service_plan.create_or_update(plan, rg)
def create_or_update(deployed, container): client = AzureClient.new_instance(container.subscription) print "Defining web site [%s] in resource group [%s]" % (deployed.appName, container.resourceName) client.create_website(container.resourceName, deployed.appName, container.resourceLocation, deployed.plan) print "Updating general settings" client.update_general_settings(container.resourceName, deployed.appName, container.resourceLocation, to_general_settings(deployed)) if deployed.appSettings.keys(): print "Updating app settings" client.update_app_settings(container.resourceName, deployed.appName, container.resourceLocation, deployed.appSettings) if deployed.sqlDatabaseConnectionStrings.keys() or deployed.sqlServerConnectionStrings.keys() or deployed.customConnectionStrings.keys(): print "Updating connection strings" client.update_db_conn_settings(container.resourceName, deployed.appName, container.resourceLocation, deployed.sqlDatabaseConnectionStrings, deployed.sqlServerConnectionStrings, deployed.customConnectionStrings) print "Done"
def stop(deployed, container): client = AzureClient.new_instance(container.subscription) print "Stopping website if already running." client.stop_continuous_webjob(deployed.webJobName, deployed.appName) print "Done"
def start(deployed, container): client = AzureClient.new_instance(container.subscription) print "Starting website if already not already running." client.start_website(container.resourceName, deployed.appName) print "Done"
def create_or_update(rg): client = AzureClient.new_instance(rg.subscription) print "Defining resource group [%s] in location [%s]" % (rg.resourceName, rg.resourceLocation) client.create_resource_group(rg.resourceName, rg.resourceLocation, rg.resourceTags) print "Done"
def check_connection(subscription): client = AzureClient.new_instance(subscription) print "Checking connection by fetching known resource groups." print client.list_resource_group_names() print "Done"
def create_or_update(deployed, container): client = AzureClient.new_instance(container.subscription) print "Defining app service plan [%s] in resource group [%s]" % (deployed.servicePlanName, container.resourceName) client.create_app_service_plan(container.resourceName, deployed.servicePlanName, deployed.location, deployed.sku, deployed.workerSize) print "Done"
def perform_discovery(subscription, ctx, resource_group_descriptor, web_app_module_descriptor, service_plan_descriptor): client = AzureClient.new_instance(subscription) discover_resource_groups(client, ctx, resource_group_descriptor, web_app_module_descriptor, service_plan_descriptor, subscription.id)
def setUp(self): self.resource_group_ci = ResourceGroupCi() self.expected_name = "xld_azure_app_service_plugin_test_rg" self.resource_group_ci.resourceName = self.expected_name self.client = AzureClient.new_instance(self.resource_group_ci.subscription)
def stop(deployed, container): client = AzureClient.new_instance(container.subscription) print "Stopping website if already running." client.stop_website(container.resourceName, deployed.appName) print "Done"