Beispiel #1
0
        private PublishContext CreatePublishContext(
            string name,
            string slot,
            string location,
            string affinityGroup,
            string storageServiceName,
            string deploymentName)
        {
            string serviceName;
            CloudServiceProject cloudServiceProject = GetCurrentServiceProject();

            // 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.CurrentStorageAccount;
            }

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

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

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

            return(context);
        }
        public void ChangeServiceNameTest()
        {
            string newName = "NodeAppService";

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
                service.ChangeServiceName(newName, service.Paths);
                Assert.AreEqual<string>(newName, service.Components.CloudConfig.serviceName);
                Assert.AreEqual<string>(newName, service.Components.LocalConfig.serviceName);
                Assert.AreEqual<string>(newName, service.Components.Definition.name);
            }
        }