Ejemplo n.º 1
0
def config_source_control(resource_group_name,
                          name,
                          repo_url,
                          repository_type=None,
                          branch=None,
                          git_token=None,
                          manual_integration=None,
                          slot=None):
    from azure.mgmt.web.models import SiteSourceControl, SourceControl
    client = web_client_factory()
    location = _get_location_from_webapp(client, resource_group_name, name)
    if git_token:
        sc = SourceControl(location, name='GitHub', token=git_token)
        client.update_source_control('GitHub', sc)

    source_control = SiteSourceControl(
        location,
        repo_url=repo_url,
        branch=branch,
        is_manual_integration=manual_integration,
        is_mercurial=(repository_type != 'git'))
    poller = _generic_site_operation(resource_group_name, name,
                                     'create_or_update_source_control', slot,
                                     source_control)
    return AppServiceLongRunningOperation()(poller)
Ejemplo n.º 2
0
def config_source_control(resource_group_name, name, repo_url, repository_type=None, branch=None,
                          manual_integration=None, slot=None):
    client = web_client_factory()
    location = _get_location_from_webapp(client, resource_group_name, name)
    source_control = SiteSourceControl(location, repo_url=repo_url, branch=branch,
                                       is_manual_integration=manual_integration,
                                       is_mercurial=(repository_type != 'git'))
    return _generic_site_operation(resource_group_name, name,
                                   'create_or_update_site_source_control',
                                   slot, source_control)
Ejemplo n.º 3
0
def config_source_control(resource_group_name,
                          name,
                          repo_url,
                          repository_type=None,
                          branch=None,
                          git_token=None,
                          manual_integration=None,
                          slot=None,
                          cd_provider=None,
                          cd_app_type=None,
                          cd_account=None,
                          cd_account_must_exist=None):
    client = web_client_factory()
    location = _get_location_from_webapp(client, resource_group_name, name)

    if cd_provider == 'vsts':
        create_account = not cd_account_must_exist
        vsts_provider = VstsContinuousDeliveryProvider()
        status = vsts_provider.setup_continuous_delivery(
            resource_group_name, name, repo_url, branch, git_token, slot,
            cd_app_type, cd_account, create_account, location)
        logger.warning(status.status_message)
        return status
    else:
        from azure.mgmt.web.models import SiteSourceControl, SourceControl
        if git_token:
            sc = SourceControl(location, name='GitHub', token=git_token)
            client.update_source_control('GitHub', sc)

        source_control = SiteSourceControl(
            location,
            repo_url=repo_url,
            branch=branch,
            is_manual_integration=manual_integration,
            is_mercurial=(repository_type != 'git'))
        return _generic_site_operation(resource_group_name, name,
                                       'create_or_update_source_control', slot,
                                       source_control)
Ejemplo n.º 4
0
WEB_APP_NAME = 'sampleflaskapp123'
REPO_URL = 'GitHub_Repository_URL'

#log in
web_client = get_client_from_cli_profile(WebSiteManagementClient)

# get service plan id
service_plan = web_client.app_service_plans.get(RESOURCE_GROUP_NAME,
                                                SERVICE_PLAN_NAME)

# create a web app
siteConfiguration = SiteConfig(python_version='3.4', )
site_async_operation = web_client.web_apps.create_or_update(
    RESOURCE_GROUP_NAME,
    WEB_APP_NAME,
    Site(location='eastus',
         server_farm_id=service_plan.id,
         site_config=siteConfiguration),
)

site = site_async_operation.result()
print('created webapp: ' + site.default_host_name)

# continuous deployment with GitHub
source_control_async_operation = web_client.web_apps.create_or_update_source_control(
    RESOURCE_GROUP_NAME, WEB_APP_NAME,
    SiteSourceControl(location='GitHub', repo_url=REPO_URL, branch='master'))

source_control = source_control_async_operation.result()
print("added source control to: " + source_control.name + "azurewebsites.net")
Ejemplo n.º 5
0
                                                SERVICE_PLAN_NAME)

# create a web app
siteConfiguration = SiteConfig(python_version='3.4', )
site_async_operation = web_client.web_apps.create_or_update(
    RESOURCE_GROUP_NAME,
    WEB_APP_NAME,
    Site(location='eastus',
         server_farm_id=service_plan.id,
         site_config=siteConfiguration),
)

site = site_async_operation.result()
print('created webapp: ' + site.default_host_name)

# continuous deployment with GitHub
source_control_async_operation = web_client.web_apps.create_or_update_source_control(
    RESOURCE_GROUP_NAME,
    WEB_APP_NAME,
    SiteSourceControl(
        is_manual_integration=True,
        is_mercurial=False,
        deployment_rollback_enabled=False,
        repo_url=REPO_URL,
        branch='master',
        # location='GitHub',
    ))

source_control = source_control_async_operation.result()
print("added source control to: " + source_control.name + ".azurewebsites.net")