本文整理汇总了C#中Microsoft.WindowsAzure.Commands.Utilities.CloudService.CloudServiceProject类的典型用法代码示例。如果您正苦于以下问题:C# CloudServiceProject类的具体用法?C# CloudServiceProject怎么用?C# CloudServiceProject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudServiceProject类属于Microsoft.WindowsAzure.Commands.Utilities.CloudService命名空间,在下文中一共展示了CloudServiceProject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAzureCacheWorkerRoleProcess
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);
}
示例2: CacheWorkerRole180
private static void CacheWorkerRole180(string rootPath, RoleInfo cacheRoleInfo)
{
// Fetch cache role information from service definition and service configuration files.
CloudServiceProject cloudServiceProject = new CloudServiceProject(rootPath, null);
WorkerRole cacheWorkerRole = cloudServiceProject.Components.GetWorkerRole(cacheRoleInfo.Name);
RoleSettings cacheRoleSettings = cloudServiceProject.Components.GetCloudConfigRole(cacheRoleInfo.Name);
// Add caching module to the role imports
cacheWorkerRole.Imports = GeneralUtilities.ExtendArray<Import>(
cacheWorkerRole.Imports,
new Import { moduleName = Resources.CachingModuleName });
// Enable caching Diagnostic store.
LocalStore diagnosticStore = new LocalStore
{
name = Resources.CacheDiagnosticStoreName,
cleanOnRoleRecycle = false
};
cacheWorkerRole.LocalResources = GeneralUtilities.InitializeIfNull<LocalResources>(cacheWorkerRole.LocalResources);
cacheWorkerRole.LocalResources.LocalStorage = GeneralUtilities.ExtendArray<LocalStore>(
cacheWorkerRole.LocalResources.LocalStorage,
diagnosticStore);
// Remove input endpoints.
cacheWorkerRole.Endpoints.InputEndpoint = null;
// Add caching configuration settings
AddCacheConfiguration(cloudServiceProject.Components.GetCloudConfigRole(cacheRoleInfo.Name));
AddCacheConfiguration(
cloudServiceProject.Components.GetLocalConfigRole(cacheRoleInfo.Name),
Resources.EmulatorConnectionString);
cloudServiceProject.Components.Save(cloudServiceProject.Paths);
}
示例3: ExecuteCmdlet
public override void ExecuteCmdlet()
{
RootPath = RootPath ?? CommonUtilities.GetServiceRootPath(CurrentPath());
CloudServiceProject service = new CloudServiceProject(RootPath, null);
RoleInfo roleInfo = null;
if (isWebRole)
{
roleInfo = service.AddWebRole(Scaffolding, Name, Instances);
}
else
{
roleInfo = service.AddWorkerRole(Scaffolding, Name, Instances);
}
OnProcessing(roleInfo);
try
{
service.ChangeRolePermissions(roleInfo);
SafeWriteOutputPSObject(typeof(RoleSettings).FullName, Parameters.RoleName, roleInfo.Name);
WriteVerbose(string.Format(successMessage, RootPath, roleInfo.Name));
}
catch (UnauthorizedAccessException)
{
WriteWarning(Resources.AddRoleMessageInsufficientPermissions);
}
}
示例4: CacheRole180
/// <summary>
/// Configuration required to enable dedicated caching on a given role.
/// </summary>
/// <param name="rootPath">The service project root path</param>
/// <param name="cacheRoleInfo">The cache role info</param>
private static void CacheRole180(string rootPath, RoleInfo cacheRoleInfo)
{
CloudServiceProject cloudServiceProject = new CloudServiceProject(rootPath, null);
if (!cloudServiceProject.Components.IsWebRole(cacheRoleInfo.Name))
{
CacheWorkerRole180(rootPath, cacheRoleInfo);
}
}
示例5: CreateLocalPackageWithNodeWorkerRoleTest
public void CreateLocalPackageWithNodeWorkerRoleTest()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWorkerRole(Test.Utilities.Common.Data.NodeWorkerRoleScaffoldingPath);
service.CreatePackage(DevEnv.Local);
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole));
}
}
示例6: SetAzureInstancesProcess
/// <summary>
/// The code to run if setting azure instances
/// </summary>
/// <param name="roleName">The name of the role to update</param>
/// <param name="instances">The new number of instances for the role</param>
/// <param name="rootPath">The root path to the service containing the role</param>
/// <returns>Role after updating instance count</returns>
public RoleSettings SetAzureInstancesProcess(string roleName, int instances, string rootPath)
{
CloudServiceProject service = new CloudServiceProject(rootPath, null);
service.SetRoleInstances(service.Paths, roleName, instances);
if (PassThru)
{
SafeWriteOutputPSObject(typeof(RoleSettings).FullName, Parameters.RoleName, roleName);
}
return service.Components.GetCloudConfigRole(roleName);
}
示例7: StartAzureEmulatorProcess
public CloudServiceProject StartAzureEmulatorProcess(string rootPath)
{
string warning;
string roleInformation;
StringBuilder message = new StringBuilder();
CloudServiceProject cloudServiceProject = new CloudServiceProject(rootPath, null);
if (Directory.Exists(cloudServiceProject.Paths.LocalPackage))
{
WriteVerbose(Resources.StopEmulatorMessage);
cloudServiceProject.StopEmulators(out warning);
if (!string.IsNullOrEmpty(warning))
{
WriteWarning(warning);
}
WriteVerbose(Resources.StoppedEmulatorMessage);
string packagePath = cloudServiceProject.Paths.LocalPackage;
WriteVerbose(string.Format(Resources.RemovePackage, packagePath));
try
{
Directory.Delete(packagePath, true);
}
catch (IOException)
{
throw new InvalidOperationException(string.Format(Resources.FailedToCleanUpLocalPackage, packagePath));
}
}
WriteVerbose(string.Format(Resources.CreatingPackageMessage, "local"));
cloudServiceProject.CreatePackage(DevEnv.Local);
WriteVerbose(Resources.StartingEmulator);
cloudServiceProject.ResolveRuntimePackageUrls();
cloudServiceProject.StartEmulators(Launch.ToBool(), Mode, out roleInformation, out warning);
WriteVerbose(roleInformation);
if (!string.IsNullOrEmpty(warning))
{
WriteWarning(warning);
}
WriteVerbose(Resources.StartedEmulator);
SafeWriteOutputPSObject(
cloudServiceProject.GetType().FullName,
Parameters.ServiceName, cloudServiceProject.ServiceName,
Parameters.RootPath, cloudServiceProject.Paths.RootPath);
return cloudServiceProject;
}
示例8: VerifyDisableRoleSettings
private static void VerifyDisableRoleSettings(CloudServiceProject service)
{
IEnumerable<RoleSettings> settings =
Enumerable.Concat(
service.Components.CloudConfig.Role,
service.Components.LocalConfig.Role);
foreach (RoleSettings roleSettings in settings)
{
Assert.Equal(
1,
roleSettings.ConfigurationSettings
.Where(c => c.name == "Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" && c.value == "false")
.Count());
}
}
示例9: NewAzureServiceProcess
internal CloudServiceProject NewAzureServiceProcess(string parentDirectory, string serviceName)
{
// Create scaffolding structure
//
CloudServiceProject newService = new CloudServiceProject(parentDirectory, serviceName, null);
SafeWriteOutputPSObject(
newService.GetType().FullName,
Parameters.ServiceName, newService.ServiceName,
Parameters.RootPath, newService.Paths.RootPath
);
WriteVerbose(string.Format(Resources.NewServiceCreatedMessage, newService.Paths.RootPath));
return newService;
}
示例10: TestStartAzureService
public void TestStartAzureService()
{
stopServiceCmdlet.ServiceName = serviceName;
stopServiceCmdlet.Slot = slot;
cloudServiceClientMock.Setup(f => f.StartCloudService(serviceName, slot));
using (FileSystemHelper files = new FileSystemHelper(this))
{
files.CreateAzureSdkDirectoryAndImportPublishSettings();
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
stopServiceCmdlet.ExecuteCmdlet();
Assert.Equal<int>(0, mockCommandRuntime.OutputPipeline.Count);
cloudServiceClientMock.Verify(f => f.StartCloudService(serviceName, slot), Times.Once());
}
}
示例11: CreateLocalPackageWithOnePHPWebRoleTest
public void CreateLocalPackageWithOnePHPWebRoleTest()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
RoleInfo webRoleInfo = service.AddWebRole(Test.Utilities.Common.Data.PHPWebRoleScaffoldingPath);
string logsDir = Path.Combine(service.Paths.RootPath, webRoleInfo.Name, "server.js.logs");
string logFile = Path.Combine(logsDir, "0.txt");
string targetLogsFile = Path.Combine(service.Paths.LocalPackage, "roles", webRoleInfo.Name, @"approot\server.js.logs\0.txt");
files.CreateDirectory(logsDir);
files.CreateEmptyFile(logFile);
service.CreatePackage(DevEnv.Local);
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole1\approot"), Path.Combine(Resources.PHPScaffolding, Resources.WebRole));
Assert.True(File.Exists(targetLogsFile));
}
}
示例12: CreateCloudPackageWithMultipleRoles
public void CreateCloudPackageWithMultipleRoles()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWorkerRole(Test.Utilities.Common.Data.NodeWorkerRoleScaffoldingPath);
service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath);
service.AddWorkerRole(Test.Utilities.Common.Data.PHPWorkerRoleScaffoldingPath);
service.AddWebRole(Test.Utilities.Common.Data.PHPWebRoleScaffoldingPath);
service.CreatePackage(DevEnv.Cloud);
using (Package package = Package.Open(service.Paths.CloudPackage))
{
Assert.Equal(9, package.GetParts().Count());
}
}
}
示例13: TestSetAzureRuntimeValidRuntimeVersions
public void TestSetAzureRuntimeValidRuntimeVersions()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath);
string roleName = "WebRole1";
cmdlet.PassThru = false;
RoleSettings roleSettings1 = cmdlet.SetAzureRuntimesProcess(roleName, "node", "0.8.2", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files));
RoleSettings roleSettings2 = cmdlet.SetAzureRuntimesProcess(roleName, "iisnode", "0.1.21", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files));
VerifyPackageJsonVersion(service.Paths.RootPath, roleName, "node", "0.8.2");
VerifyPackageJsonVersion(service.Paths.RootPath, roleName, "iisnode", "0.1.21");
Assert.Equal<int>(0, mockCommandRuntime.OutputPipeline.Count);
Assert.Equal<string>(roleName, roleSettings1.name);
Assert.Equal<string>(roleName, roleSettings2.name);
}
}
示例14: SetAzureVMSizeProcessTestsNode
public void SetAzureVMSizeProcessTestsNode()
{
string newRoleVMSize = "Large";
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
string roleName = "WebRole1";
service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath);
cmdlet.PassThru = false;
RoleSettings roleSettings = cmdlet.SetAzureVMSizeProcess("WebRole1", newRoleVMSize, service.Paths.RootPath);
service = new CloudServiceProject(service.Paths.RootPath, null);
Assert.Equal<string>(newRoleVMSize, service.Components.Definition.WebRole[0].vmsize.ToString());
Assert.Equal<int>(0, mockCommandRuntime.OutputPipeline.Count);
Assert.Equal<string>(roleName, roleSettings.name);
}
}
示例15: DisableRemoteDesktop
public void DisableRemoteDesktop()
{
CloudServiceProject service = new CloudServiceProject(CommonUtilities.GetServiceRootPath(CurrentPath()), null);
WebRole[] webRoles = service.Components.Definition.WebRole ?? new WebRole[0];
WorkerRole[] workerRoles = service.Components.Definition.WorkerRole ?? new WorkerRole[0];
string forwarderName = GetForwarderName(webRoles, workerRoles);
if (forwarderName != null)
{
UpdateServiceConfigurations(service, forwarderName);
service.Components.Save(service.Paths);
}
if (PassThru)
{
WriteObject(true);
}
}