예제 #1
0
        public static ServiceSettings GetDefaultSettings(
            string rootPath,
            string inServiceName,
            string slot,
            string location,
            string affinityGroup,
            string storageName,
            string subscription,
            out string serviceName)
        {
            ServiceSettings serviceSettings;

            if (string.IsNullOrEmpty(rootPath))
            {
                serviceSettings = ServiceSettings.LoadDefault(null, slot, location, affinityGroup, subscription, storageName, inServiceName, null, out serviceName);
            }
            else
            {
                serviceSettings = ServiceSettings.LoadDefault(
                    new CloudServiceProject(rootPath, null).Paths.Settings,
                    slot,
                    location,
                    affinityGroup,
                    subscription,
                    storageName,
                    inServiceName,
                    new CloudServiceProject(rootPath, null).ServiceName,
                    out serviceName);
            }

            return(serviceSettings);
        }
예제 #2
0
        protected ServiceSettings GetDefaultSettings(string rootPath, string inServiceName, string slot, string location, string storageName, string subscription, out string serviceName)
        {
            ServiceSettings serviceSettings;

            if (string.IsNullOrEmpty(rootPath))
            {
                serviceSettings = ServiceSettings.LoadDefault(null, slot, location, subscription, storageName, inServiceName, null, out serviceName);
            }
            else
            {
                serviceSettings = ServiceSettings.LoadDefault(new AzureService(rootPath, null).Paths.Settings,
                                                              slot, location, subscription, storageName, inServiceName, new AzureService(rootPath, null).ServiceName, out serviceName);
            }

            return(serviceSettings);
        }
예제 #3
0
        public void GetDefaultLocationWithUnknwonLocation()
        {
            // Create a temp directory that we'll use to "publish" our service
            using (FileSystemHelper files = new FileSystemHelper(this)
            {
                EnableMonitoring = true
            })
            {
                // Import our default publish settings
                files.CreateAzureSdkDirectoryAndImportPublishSettings();
                string serviceName     = null;
                string unknownLocation = "Unknown Location";

                ServiceSettings settings = ServiceSettings.LoadDefault(null, null, unknownLocation, null, null, null, "My-Custom-Service!", null, out serviceName);
                Assert.AreEqual <string>(unknownLocation.ToLower(), settings.Location.ToLower());
            }
        }
예제 #4
0
        public void InvalidStorageAccountName()
        {
            // Create a temp directory that we'll use to "publish" our service
            using (FileSystemHelper files = new FileSystemHelper(this)
            {
                EnableMonitoring = true
            })
            {
                // Import our default publish settings
                files.CreateAzureSdkDirectoryAndImportPublishSettings();

                string serviceName = null;
                Testing.AssertThrows <ArgumentException>(() =>
                                                         ServiceSettings.LoadDefault(null, null, null, null, null, "I HAVE INVALID CHARACTERS !@#$%", null, null, out serviceName));
                Testing.AssertThrows <ArgumentException>(() =>
                                                         ServiceSettings.LoadDefault(null, null, null, null, null, "ihavevalidcharsbutimjustwaytooooooooooooooooooooooooooooooooooooooooolong", null, null, out serviceName));
            }
        }
예제 #5
0
        public void SanitizeServiceNameForStorageAccountName()
        {
            // Create a temp directory that we'll use to "publish" our service
            using (FileSystemHelper files = new FileSystemHelper(this)
            {
                EnableMonitoring = true
            })
            {
                // Import our default publish settings
                files.CreateAzureSdkDirectoryAndImportPublishSettings();

                string          serviceName = null;
                ServiceSettings settings    = ServiceSettings.LoadDefault(null, null, null, null, null, null, "My-Custom-Service!", null, out serviceName);
                Assert.AreEqual("myx2dcustomx2dservicex21", settings.StorageServiceName);

                settings = ServiceSettings.LoadDefault(null, null, null, null, null, null, "MyCustomServiceIsWayTooooooooooooooooooooooooLong", null, out serviceName);
                Assert.AreEqual("mycustomserviceiswaytooo", settings.StorageServiceName);
            }
        }
예제 #6
0
        /// <summary>
        /// Initialize our model of the AzureService located at the given
        /// path along with its DeploymentSettings and SubscriptionId.
        /// </summary>
        /// <param name="rootPath">Root path of the Azure service.</param>
        internal void InitializeSettingsAndCreatePackage(string rootPath)
        {
            Debug.Assert(!string.IsNullOrEmpty(rootPath), "rootPath cannot be null or empty.");
            Debug.Assert(Directory.Exists(rootPath), "rootPath does not exist.");

            _azureService = new AzureService(rootPath, null);

            // If user provided a service name, change current service name to use it.
            //
            if (!string.IsNullOrEmpty(Name))
            {
                _azureService.ChangeServiceName(Name, _azureService.Paths);
            }

            ServiceSettings defaultSettings = ServiceSettings.LoadDefault(
                _azureService.Paths.Settings,
                Slot,
                Location,
                Subscription,
                StorageAccountName,
                Name,
                _azureService.ServiceName,
                out _hostedServiceName);

            subscriptionId =
                new GlobalComponents(GlobalPathInfo.GlobalSettingsDirectory)
                .GetSubscriptionId(defaultSettings.Subscription);

            SafeWriteObjectWithTimestamp(String.Format(Resources.PublishPreparingDeploymentMessage,
                                                       _hostedServiceName, subscriptionId));

            UpdateLocation(_azureService.Paths.Definition, defaultSettings.Location.ToUpper());

            CreatePackage();

            _deploymentSettings = new DeploymentSettings(
                defaultSettings,
                _azureService.Paths.CloudPackage,
                _azureService.Paths.CloudConfiguration,
                _hostedServiceName,
                string.Format(Resources.ServiceDeploymentName, defaultSettings.Slot));
        }