def setup_continuous_delivery(self, resource_group_name, name, repo_url, branch, git_token, slot, cd_app_type_details, cd_project_url, cd_create_account, location, test, private_repo_username, private_repo_password, webapp_list): """ This method sets up CD for an Azure Web App thru Team Services """ # Gather information about the Azure connection profile = Profile() subscription = profile.get_subscription() user = profile.get_current_account_user() cred, _, _ = profile.get_login_credentials(subscription_id=None) cd_manager = ContinuousDeliveryManager(self._update_progress) # Generate an Azure token with the VSTS resource app id auth_token = profile.get_access_token_for_resource( user, None, cd_manager.get_vsts_app_id()) cd_manager.set_repository_info(repo_url, branch, git_token, private_repo_username, private_repo_password) cd_manager.set_azure_web_info(resource_group_name, name, cred, subscription['id'], subscription['name'], subscription['tenantId'], location) vsts_cd_status = cd_manager.setup_continuous_delivery( slot, cd_app_type_details, cd_project_url, cd_create_account, auth_token, test, webapp_list) return vsts_cd_status
def setup_continuous_delivery(self, cli_ctx, resource_group_name, name, repo_url, branch, git_token, slot, cd_app_type_details, cd_project_url, cd_create_account, location, test, private_repo_username, private_repo_password, webapp_list): """ This method sets up CD for an Azure Web App thru Team Services """ # Gather information about the Azure connection profile = Profile(cli_ctx=cli_ctx) subscription = profile.get_subscription() user = profile.get_current_account_user() cred, _, _ = profile.get_login_credentials(subscription_id=None) cd_manager = ContinuousDeliveryManager(self._update_progress) # Generate an Azure token with the VSTS resource app id auth_token = profile.get_access_token_for_resource(user, None, cd_manager.get_vsts_app_id()) cd_manager.set_repository_info(repo_url, branch, git_token, private_repo_username, private_repo_password) cd_manager.set_azure_web_info(resource_group_name, name, cred, subscription['id'], subscription['name'], subscription['tenantId'], location) vsts_cd_status = cd_manager.setup_continuous_delivery(slot, cd_app_type_details, cd_project_url, cd_create_account, auth_token, test, webapp_list) return vsts_cd_status
def get_auth_header(cmd): from azure.cli.core._profile import Profile from ._constants import CLIENT_ID profile = Profile(cli_ctx=cmd.cli_ctx) account = profile.get_subscription() access_token = profile.get_access_token_for_resource( account['user']['name'], account['tenantId'], CLIENT_ID) return {'Authorization': '{}'.format('Bearer ' + access_token)}