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

AddWorkerRole() public method

public AddWorkerRole ( string scaffolding, string name = null, int instanceCount = 1 ) : RoleInfo
scaffolding string
name string
instanceCount int
return RoleInfo
        public RoleInfo AddWorkerRole(
            string scaffolding,
            string name = null,
            int instanceCount = 1)
        {
            name = GetRoleName(name, Resources.WorkerRole, Components.Definition.WorkerRole == null ? 
                new string[0] : 
                Components.Definition.WorkerRole.Select(wr => wr.name.ToLower()));
            
            WorkerRoleInfo role = new WorkerRoleInfo(name, instanceCount);
            
            AddRoleCore(scaffolding, role);

            return role;
        }

Usage Example

        public WorkerRole AddAzureCacheWorkerRoleProcess(string workerRoleName, int instances, string rootPath)
        {
            // Create cache worker role.
            Action<string, RoleInfo> cacheWorkerRoleAction = CacheConfigurationFactory.GetCacheRoleConfigurationAction(
                AzureTool.GetAzureSdkVersion());

            CloudServiceProject cloudServiceProject = new CloudServiceProject(rootPath, null);
            
            RoleInfo genericWorkerRole = cloudServiceProject.AddWorkerRole(
                Path.Combine(Resources.GeneralScaffolding, RoleType.WorkerRole.ToString()),
                workerRoleName,
                instances);

            // Dedicate the worker role for caching.
            cacheWorkerRoleAction(cloudServiceProject.Paths.RootPath, genericWorkerRole);

            cloudServiceProject.Reload();
            WorkerRole cacheWorkerRole = cloudServiceProject.Components.GetWorkerRole(genericWorkerRole.Name);

            // Write output
            SafeWriteOutputPSObject(
                cacheWorkerRole.GetType().FullName,
                Parameters.CacheWorkerRoleName, genericWorkerRole.Name,
                Parameters.Instances, genericWorkerRole.InstanceCount
                );

            return cloudServiceProject.Components.GetWorkerRole(workerRoleName);
        }
All Usage Examples Of Microsoft.WindowsAzure.Commands.Utilities.CloudService.CloudServiceProject::AddWorkerRole