Microsoft.WindowsAzure.Commands.Utilities.CloudService.ServiceSettings.LoadDefault C# (CSharp) Method

LoadDefault() public static method

public static LoadDefault ( string path, string slot, string location, string affinityGroup, string subscription, string storageAccountName, string suppliedServiceName, string serviceDefinitionName, string &serviceName ) : ServiceSettings
path string
slot string
location string
affinityGroup string
subscription string
storageAccountName string
suppliedServiceName string
serviceDefinitionName string
serviceName string
return ServiceSettings
        public static ServiceSettings LoadDefault(
            string path,
            string slot,
            string location,
            string affinityGroup,
            string subscription,
            string storageAccountName,
            string suppliedServiceName,
            string serviceDefinitionName,
            out string serviceName)
        {
            ServiceSettings local;
            ServiceSettings defaultServiceSettings = new ServiceSettings();

            if (string.IsNullOrEmpty(path) || !File.Exists(path))
            {
                local = new ServiceSettings();
            }
            else
            {
                Validate.ValidateFileFull(path, Resources.ServiceSettings);
                local = Load(path);
            }

            defaultServiceSettings._slot = GetDefaultSlot(local.Slot, null, slot);
            defaultServiceSettings._location = GetDefaultLocation(local.Location, location);
            defaultServiceSettings._subscription = GetDefaultSubscription(local.Subscription, subscription);
            serviceName = GetServiceName(suppliedServiceName, serviceDefinitionName);
            defaultServiceSettings._storageAccountName = GetDefaultStorageName(local.StorageServiceName, null, storageAccountName, serviceName).ToLower();
            defaultServiceSettings._affinityGroup = affinityGroup;

            return defaultServiceSettings;
        }

Usage Example

Ejemplo n.º 1
0
        private PublishContext CreatePublishContext(
            string name,
            string slot,
            string location,
            string affinityGroup,
            string storageServiceName,
            string deploymentName,
            CloudServiceProject cloudServiceProject)
        {
            string serviceName;

            // If the name provided is different than existing name change it
            if (!string.IsNullOrEmpty(name) && name != cloudServiceProject.ServiceName)
            {
                cloudServiceProject.ChangeServiceName(name, cloudServiceProject.Paths);
            }

            // If there's no storage service provided, try using the default one
            if (string.IsNullOrEmpty(storageServiceName))
            {
                storageServiceName = Subscription.GetProperty(AzureSubscription.Property.StorageAccount);
            }

            ServiceSettings serviceSettings = ServiceSettings.LoadDefault(
                cloudServiceProject.Paths.Settings,
                slot,
                location,
                affinityGroup,
                Subscription.Name,
                storageServiceName,
                name,
                cloudServiceProject.ServiceName,
                out serviceName
                );

            // Use default location if not location and affinity group provided
            serviceSettings.Location = string.IsNullOrEmpty(serviceSettings.Location) &&
                                       string.IsNullOrEmpty(serviceSettings.AffinityGroup) ?
                                       GetDefaultLocation() : serviceSettings.Location;

            PublishContext context = new PublishContext(
                serviceSettings,
                Path.Combine(GetCurrentDirectory(), cloudServiceProject.Paths.CloudPackage),
                Path.Combine(GetCurrentDirectory(), cloudServiceProject.Paths.CloudConfiguration),
                serviceName,
                deploymentName,
                cloudServiceProject.Paths.RootPath);

            context.ServiceProject = cloudServiceProject;

            return(context);
        }