本文整理汇总了C#中CloudServiceProject.AddWebRole方法的典型用法代码示例。如果您正苦于以下问题:C# CloudServiceProject.AddWebRole方法的具体用法?C# CloudServiceProject.AddWebRole怎么用?C# CloudServiceProject.AddWebRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CloudServiceProject
的用法示例。
在下文中一共展示了CloudServiceProject.AddWebRole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateLocalPackageWithOnePHPWebRoleTest
public void CreateLocalPackageWithOnePHPWebRoleTest()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
RoleInfo webRoleInfo = service.AddWebRole(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.IsTrue(File.Exists(targetLogsFile));
}
}
示例2: TestSetAzureRuntimeValidRuntimeVersions
public void TestSetAzureRuntimeValidRuntimeVersions()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWebRole(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.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count);
Assert.AreEqual<string>(roleName, roleSettings1.name);
Assert.AreEqual<string>(roleName, roleSettings2.name);
}
}
示例3: SetAzureVMSizeProcessTestsNode
public void SetAzureVMSizeProcessTestsNode()
{
string newRoleVMSize = RoleSize.Large.ToString();
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
string roleName = "WebRole1";
service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
cmdlet.PassThru = false;
RoleSettings roleSettings = cmdlet.SetAzureVMSizeProcess("WebRole1", newRoleVMSize, service.Paths.RootPath);
service = new CloudServiceProject(service.Paths.RootPath, null);
Assert.AreEqual<string>(newRoleVMSize, service.Components.Definition.WebRole[0].vmsize.ToString());
Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count);
Assert.AreEqual<string>(roleName, roleSettings.name);
}
}
示例4: SetAzureVMSizeProcessTestsPHP
public void SetAzureVMSizeProcessTestsPHP()
{
string newRoleVMSize = RoleSize.Medium.ToString();
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
string roleName = "WebRole1";
service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
RoleSettings roleSettings = cmdlet.SetAzureVMSizeProcess("WebRole1", newRoleVMSize, service.Paths.RootPath);
service = new CloudServiceProject(service.Paths.RootPath, null);
Assert.AreEqual<string>(newRoleVMSize, service.Components.Definition.WebRole[0].vmsize.ToString());
Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).Members[Parameters.RoleName].Value.ToString());
Assert.IsTrue(((PSObject)mockCommandRuntime.OutputPipeline[0]).TypeNames.Contains(typeof(RoleSettings).FullName));
Assert.AreEqual<string>(roleName, roleSettings.name);
}
}
示例5: SetAzureInstancesProcessTestsPHP
public void SetAzureInstancesProcessTestsPHP()
{
int newRoleInstances = 10;
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
string roleName = "WebRole1";
service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
RoleSettings roleSettings = cmdlet.SetAzureInstancesProcess("WebRole1", newRoleInstances, service.Paths.RootPath);
service = new CloudServiceProject(service.Paths.RootPath, null);
Assert.AreEqual<int>(newRoleInstances, service.Components.CloudConfig.Role[0].Instances.count);
Assert.AreEqual<int>(newRoleInstances, service.Components.LocalConfig.Role[0].Instances.count);
Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).Members[Parameters.RoleName].Value.ToString());
Assert.IsTrue(((PSObject)mockCommandRuntime.OutputPipeline[0]).TypeNames.Contains(typeof(RoleSettings).FullName));
Assert.AreEqual<int>(newRoleInstances, roleSettings.Instances.count);
Assert.AreEqual<string>(roleName, roleSettings.name);
}
}
示例6: TestCreatePackageSuccessfull
public void TestCreatePackageSuccessfull()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
files.CreateAzureSdkDirectoryAndImportPublishSettings();
files.CreateNewService("NEW_SERVICE");
string rootPath = Path.Combine(files.RootPath, "NEW_SERVICE");
string packagePath = Path.Combine(rootPath, Resources.CloudPackageFileName);
CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services"));
service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
cmdlet.ExecuteCmdlet();
PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject;
Assert.AreEqual<string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]);
Assert.AreEqual<string>(packagePath, obj.GetVariableValue<string>(Parameters.PackagePath));
Assert.IsTrue(File.Exists(packagePath));
}
}
示例7: SetAzureInstancesProcessTestsNode
public void SetAzureInstancesProcessTestsNode()
{
int newRoleInstances = 10;
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
string roleName = "WebRole1";
service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
cmdlet.PassThru = false;
RoleSettings roleSettings = cmdlet.SetAzureInstancesProcess("WebRole1", newRoleInstances, service.Paths.RootPath);
service = new CloudServiceProject(service.Paths.RootPath, null);
Assert.AreEqual<int>(newRoleInstances, service.Components.CloudConfig.Role[0].Instances.count);
Assert.AreEqual<int>(newRoleInstances, service.Components.LocalConfig.Role[0].Instances.count);
Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count);
Assert.AreEqual<int>(newRoleInstances, roleSettings.Instances.count);
Assert.AreEqual<string>(roleName, roleSettings.name);
}
}
示例8: CreateCloudPackageWithMultipleRoles
public void CreateCloudPackageWithMultipleRoles()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
service.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath);
service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
service.CreatePackage(DevEnv.Cloud);
using (Package package = Package.Open(service.Paths.CloudPackage))
{
Assert.AreEqual(9, package.GetParts().Count());
}
}
}
示例9: GetNextPortAddingThirdEndpoint
public void GetNextPortAddingThirdEndpoint()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
int expectedPort = int.Parse(Resources.DefaultPort) + 1;
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
service = new AzureServiceWrapper(service.Paths.RootPath, null);
int nextPort = service.Components.GetNextPort();
Assert.AreEqual<int>(expectedPort, nextPort);
}
}
示例10: GetNextPortWithEmptyPortIndpoints
public void GetNextPortWithEmptyPortIndpoints()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
int expectedPort = int.Parse(Resources.DefaultPort);
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
service.Components.Definition.WebRole[0].Endpoints.InputEndpoint = null;
service.Components.Save(service.Paths);
service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
service = new AzureServiceWrapper(service.Paths.RootPath, null);
int nextPort = service.Components.GetNextPort();
Assert.AreEqual<int>(expectedPort, nextPort);
}
}
示例11: GetNextPortNullPHPWebEndpointAndWorkerRole
public void GetNextPortNullPHPWebEndpointAndWorkerRole()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
int expectedPort = int.Parse(Resources.DefaultPort);
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
service.Components.Definition.WebRole.ToList().ForEach(wr => wr.Endpoints = null);
service.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath);
service = new CloudServiceProject(service.Paths.RootPath, null);
int nextPort = service.Components.GetNextPort();
Assert.AreEqual<int>(expectedPort, nextPort);
}
}
示例12: TestPublishWithDefaultLocation
public void TestPublishWithDefaultLocation()
{
RemoveDeployments();
clientMocks.ComputeManagementClientMock.Setup(
c =>
c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>()))
.Returns(Tasks.FromResult(new OperationResponse
{
RequestId = "request001",
StatusCode = HttpStatusCode.OK
}));
clientMocks.ManagementClientMock.Setup(c => c.Locations.ListAsync(It.IsAny<CancellationToken>()))
.Returns(Tasks.FromResult(new LocationsListResponse
{
Locations =
{
new LocationsListResponse.Location {DisplayName = "East US", Name = "EastUS"}
}
}));
using (var files = new FileSystemHelper(this) { EnableMonitoring = true })
{
// Setup
string rootPath = files.CreateNewService(serviceName);
files.CreateAzureSdkDirectoryAndImportPublishSettings();
var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services"));
cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath);
ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService());
clientMocks.ManagementClientMock.Verify(c => c.Locations.ListAsync(It.IsAny<CancellationToken>()), Times.Once);
}
}
示例13: TestPublishWithCurrentStorageAccount
public void TestPublishWithCurrentStorageAccount()
{
RemoveDeployments();
clientMocks.ComputeManagementClientMock.Setup(
c =>
c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>()))
.Returns(Tasks.FromResult(new OperationResponse
{
RequestId = "request001",
StatusCode = HttpStatusCode.OK
}));
using (var files = new FileSystemHelper(this) { EnableMonitoring = true })
{
// Setup
string rootPath = files.CreateNewService(serviceName);
files.CreateAzureSdkDirectoryAndImportPublishSettings();
var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services"));
cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath);
subscription.CurrentStorageAccountName = storageName;
ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US"));
cloudBlobUtilityMock.Verify(f => f.UploadPackageToBlob(
clientMocks.StorageManagementClientMock.Object,
subscription.CurrentStorageAccountName,
It.IsAny<string>(),
It.IsAny<BlobRequestOptions>()), Times.Once());
}
}
示例14: TestUpgradeCloudService
public void TestUpgradeCloudService()
{
clientMocks.ComputeManagementClientMock.Setup(
c =>
c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>()))
.Returns(Tasks.FromResult(new OperationResponse
{
RequestId = "request001",
StatusCode = HttpStatusCode.OK
}));
clientMocks.ComputeManagementClientMock.Setup(
c =>
c.Deployments.UpgradeBySlotAsync(It.IsAny<string>(), DeploymentSlot.Production,
It.IsAny<DeploymentUpgradeParameters>(),
It.IsAny<CancellationToken>()))
.Returns(Tasks.FromResult(CreateComputeOperationResponse("req002")));
using (var files = new FileSystemHelper(this) { EnableMonitoring = true })
{
// Setup
string rootPath = files.CreateNewService(serviceName);
files.CreateAzureSdkDirectoryAndImportPublishSettings();
var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services"));
cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath);
ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US"));
clientMocks.ComputeManagementClientMock.Verify(c => c.Deployments.UpgradeBySlotAsync(serviceName, DeploymentSlot.Production, It.IsAny<DeploymentUpgradeParameters>(), It.IsAny<CancellationToken>()), Times.Once);
}
}
示例15: CreateLocalPackageWithMultipleRoles
public void CreateLocalPackageWithMultipleRoles()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
service.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath);
service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
service.CreatePackage(DevEnv.Local);
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole));
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WebRole));
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole2\approot"), Path.Combine(Resources.PHPScaffolding, Resources.WorkerRole));
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole2\approot"), Path.Combine(Resources.PHPScaffolding, Resources.WebRole));
}
}