Ejemplo n.º 1
0
        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
            }
        }
Ejemplo n.º 3
0
 public static async Task <ServiceClientCredentials> Credentials(this AzureServicePrincipalAccount account)
 {
     return(new TokenCredentials(await GetAuthorizationToken(account)));
 }
Ejemplo n.º 4
0
 static Task <string> GetAuthorizationToken(AzureServicePrincipalAccount account)
 {
     return(ServicePrincipal.GetAuthorizationToken(account.TenantId, account.ClientId, account.Password,
                                                   account.ResourceManagementEndpointBaseUri, account.ActiveDirectoryEndpointBaseUri));
 }
Ejemplo n.º 5
0
 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
     });
 }