Microsoft.WindowsAzure.Commands.Utilities.CloudService.CloudServiceProject.ChangeServiceName C# (CSharp) Method

ChangeServiceName() public method

public ChangeServiceName ( string newName, CloudProjectPathInfo paths ) : void
newName string
paths CloudProjectPathInfo
return void
        public void ChangeServiceName(string newName, CloudProjectPathInfo paths)
        {
            Validate.ValidateDnsName(newName, "service name");

            Components.Definition.name = newName;
            Components.CloudConfig.serviceName = newName;
            Components.LocalConfig.serviceName = newName;
            Components.Save(paths);
        }

Usage Example

Esempio 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);
        }
All Usage Examples Of Microsoft.WindowsAzure.Commands.Utilities.CloudService.CloudServiceProject::ChangeServiceName