Task <WebDeployPublishSettings> GetPublishProfile(IVariables variables) { var account = new AzureServicePrincipalAccount(variables); var siteAndSlotName = variables.Get(SpecialVariables.Action.Azure.WebAppName); var slotName = variables.Get(SpecialVariables.Action.Azure.WebAppSlot); var targetSite = AzureWebAppHelper.GetAzureTargetSite(siteAndSlotName, slotName); return(resourceManagerPublishProfileProvider.GetPublishProperties(account, variables.Get(SpecialVariables.Action.Azure.ResourceGroupName, string.Empty), targetSite)); }
public async Task Execute(RunningDeployment deployment) { try { var variables = deployment.Variables; var resourceGroupName = variables.Get(SpecialVariables.Action.Azure.ResourceGroupName, string.Empty); var siteAndSlotName = variables.Get(SpecialVariables.Action.Azure.WebAppName); var azureEnvironment = variables.Get(SpecialVariables.Action.Azure.Environment); var account = new AzureServicePrincipalAccount(variables); var client = await account.CreateWebSiteManagementClient(); var site = await client.WebApps.GetAsync(resourceGroupName, siteAndSlotName); if (site != null) { var portalUrl = GetAzurePortalUrl(azureEnvironment); log.Info($"Default Host Name: {site.DefaultHostName}"); log.Info($"Application state: {site.State}"); log.Info("Links:"); log.Info(log.FormatLink($"https://{site.DefaultHostName}")); if (!site.HttpsOnly.HasValue || site.HttpsOnly == false) { log.Info(log.FormatLink($"http://{site.DefaultHostName}")); } var portalUri = $"https://{portalUrl}/#@/resource{site.Id}"; log.Info(log.FormatLink(portalUri, "View in Azure Portal")); } } catch { // do nothing } }
public static async Task <ServiceClientCredentials> Credentials(this AzureServicePrincipalAccount account) { return(new TokenCredentials(await GetAuthorizationToken(account))); }
static Task <string> GetAuthorizationToken(AzureServicePrincipalAccount account) { return(ServicePrincipal.GetAuthorizationToken(account.TenantId, account.ClientId, account.Password, account.ResourceManagementEndpointBaseUri, account.ActiveDirectoryEndpointBaseUri)); }
public static async Task <WebSiteManagementClient> CreateWebSiteManagementClient(this AzureServicePrincipalAccount account) { return(string.IsNullOrWhiteSpace(account.ResourceManagementEndpointBaseUri) ? new WebSiteManagementClient(await account.Credentials()) { SubscriptionId = account.SubscriptionNumber } : new WebSiteManagementClient(new Uri(account.ResourceManagementEndpointBaseUri), await account.Credentials()) { SubscriptionId = account.SubscriptionNumber }); }