Exemplo n.º 1
0
        private static SitePublishProfile GetPublishProfile(VariableDictionary variables)
        {
            var subscriptionId = variables.Get(SpecialVariables.Action.Azure.SubscriptionId);
            var siteName       = variables.Get(SpecialVariables.Action.Azure.WebAppName);

            var accountType             = variables.Get(SpecialVariables.Account.AccountType);
            var activeDirectoryEndpoint = variables.Get(SpecialVariables.Action.Azure.ActiveDirectoryEndPoint, DefaultVariables.ActiveDirectoryEndpoint);

            switch (accountType)
            {
            case AzureAccountTypes.ServicePrincipalAccountType:
                var resourceManagementEndpoint = variables.Get(SpecialVariables.Action.Azure.ResourceManagementEndPoint, DefaultVariables.ResourceManagementEndpoint);
                return(ResourceManagerPublishProfileProvider.GetPublishProperties(subscriptionId,
                                                                                  variables.Get(SpecialVariables.Action.Azure.ResourceGroupName, string.Empty),
                                                                                  siteName,
                                                                                  variables.Get(SpecialVariables.Action.Azure.TenantId),
                                                                                  variables.Get(SpecialVariables.Action.Azure.ClientId),
                                                                                  variables.Get(SpecialVariables.Action.Azure.Password),
                                                                                  resourceManagementEndpoint,
                                                                                  activeDirectoryEndpoint));

            case AzureAccountTypes.ManagementCertificateAccountType:
                var serviceManagementEndpoint = variables.Get(SpecialVariables.Action.Azure.ServiceManagementEndPoint, DefaultVariables.ServiceManagementEndpoint);
                return(ServiceManagementPublishProfileProvider.GetPublishProperties(subscriptionId,
                                                                                    Convert.FromBase64String(variables.Get(SpecialVariables.Action.Azure.CertificateBytes)),
                                                                                    siteName,
                                                                                    serviceManagementEndpoint));

            default:
                throw new CommandException(
                          "Account type must be either Azure Management Certificate or Azure Service Principal");
            }
        }
Exemplo n.º 2
0
        private static WebDeployPublishSettings GetPublishProfile(VariableDictionary variables)
        {
            var account = AccountFactory.Create(variables);

            var siteAndSlotName = variables.Get(SpecialVariables.Action.Azure.WebAppName);
            var slotName        = variables.Get(SpecialVariables.Action.Azure.WebAppSlot);

            var targetSite = AzureWebAppHelper.GetAzureTargetSite(siteAndSlotName, slotName);

            if (account is AzureServicePrincipalAccount servicePrincipalAccount)
            {
                return(ResourceManagerPublishProfileProvider.GetPublishProperties(servicePrincipalAccount,
                                                                                  variables.Get(SpecialVariables.Action.Azure.ResourceGroupName, string.Empty),
                                                                                  targetSite));
            }
            else if (account is AzureAccount azureAccount)
            {
                return(new WebDeployPublishSettings(targetSite.Site, ServiceManagementPublishProfileProvider.GetPublishProperties(azureAccount, targetSite)));
            }

            throw new CommandException("Account type must be either Azure Management Certificate or Azure Service Principal");
        }