Esempio n. 1
0
 void ConfirmWebAppExists(AzureServicePrincipalAccount servicePrincipalAccount, string resourceGroupName, string siteAndSlotName)
 {
     using (var webSiteClient = servicePrincipalAccount.CreateWebSiteManagementClient())
     {
         var matchingSite = webSiteClient.WebApps
                            .ListByResourceGroup(resourceGroupName, true)
                            .ToList()
                            .FirstOrDefault(x => string.Equals(x.Name, siteAndSlotName, StringComparison.OrdinalIgnoreCase));
         if (matchingSite == null)
         {
             throw new Exception($"Could not find site {siteAndSlotName} in resource group {resourceGroupName}, using Service Principal with subscription {servicePrincipalAccount.SubscriptionNumber}");
         }
     }
 }
Esempio n. 2
0
        public void Install(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 = account.CreateWebSiteManagementClient();
                var site   = client?.WebApps.Get(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}"));
                    }

                    string portalUri = $"https://{portalUrl}/#@/resource{site.Id}";

                    log.Info(log.FormatLink(portalUri, "View in Azure Portal"));
                }
            }
            catch
            {
                // do nothing
            }
        }