本文整理汇总了C#中Microsoft.WindowsAzure.Management.Utilities.CloudService.AzureService类的典型用法代码示例。如果您正苦于以下问题:C# AzureService类的具体用法?C# AzureService怎么用?C# AzureService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AzureService类属于Microsoft.WindowsAzure.Management.Utilities.CloudService命名空间,在下文中一共展示了AzureService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveAzureServiceProcessTest
public void RemoveAzureServiceProcessTest()
{
bool serviceDeleted = false;
bool deploymentDeleted = false;
channel.GetDeploymentBySlotThunk = ar =>
{
if (deploymentDeleted) throw new ServiceManagementClientException(HttpStatusCode.NotFound, new ServiceManagementError(), string.Empty);
return new Deployment{Name = serviceName, DeploymentSlot = ArgumentConstants.Slots[SlotType.Production], Status = DeploymentStatus.Suspended};
};
channel.DeleteHostedServiceThunk = ar => serviceDeleted = true;
channel.DeleteDeploymentBySlotThunk = ar =>
{
deploymentDeleted = true;
};
channel.IsDNSAvailableThunk = ida => new AvailabilityResponse { Result = false };
using (FileSystemHelper files = new FileSystemHelper(this))
{
files.CreateAzureSdkDirectoryAndImportPublishSettings();
AzureService service = new AzureService(files.RootPath, serviceName, null);
removeServiceCmdlet.PassThru = true;
removeServiceCmdlet.RemoveAzureServiceProcess(service.Paths.RootPath, string.Empty, serviceName);
Assert.IsTrue(deploymentDeleted);
Assert.IsTrue(serviceDeleted);
Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[0]);
}
}
示例2: StartAzureEmulatorProcess
public AzureService StartAzureEmulatorProcess(string rootPath)
{
string standardOutput;
string standardError;
StringBuilder message = new StringBuilder();
AzureService service = new AzureService(rootPath ,null);
if (Directory.Exists(service.Paths.LocalPackage))
{
WriteVerbose(Resources.StopEmulatorMessage);
service.StopEmulator(out standardOutput, out standardError);
WriteVerbose(Resources.StoppedEmulatorMessage);
WriteVerbose(string.Format(Resources.RemovePackage, service.Paths.LocalPackage));
Directory.Delete(service.Paths.LocalPackage, true);
}
WriteVerbose(string.Format(Resources.CreatingPackageMessage, "local"));
service.CreatePackage(DevEnv.Local, out standardOutput, out standardError);
WriteVerbose(Resources.StartingEmulator);
service.StartEmulator(Launch.ToBool(), out standardOutput, out standardError);
WriteVerbose(standardOutput);
WriteVerbose(Resources.StartedEmulator);
SafeWriteOutputPSObject(
service.GetType().FullName,
Parameters.ServiceName, service.ServiceName,
Parameters.RootPath, service.Paths.RootPath);
return service;
}
示例3: SetDeploymentStatusProcessDeploymentDoesNotExistTest
public void SetDeploymentStatusProcessDeploymentDoesNotExistTest()
{
SimpleServiceManagement channel = new SimpleServiceManagement();
string newStatus = DeploymentStatus.Running;
string resultMessage;
string expectedMessage = string.Format(Resources.ServiceSlotDoesNotExist, slot, serviceName);
bool statusUpdated = false;
channel.UpdateDeploymentStatusBySlotThunk = ar =>
{
statusUpdated = true;
channel.GetDeploymentBySlotThunk = ar2 => new Deployment{Name = serviceName, DeploymentSlot = slot, Status = newStatus};
};
channel.GetDeploymentBySlotThunk = ar => { throw new ServiceManagementClientException(HttpStatusCode.NotFound, new ServiceManagementError(), string.Empty); };
using (FileSystemHelper files = new FileSystemHelper(this))
{
files.CreateAzureSdkDirectoryAndImportPublishSettings();
AzureService service = new AzureService(files.RootPath, serviceName, null);
var deploymentManager = new DeploymentStatusManager(channel);
deploymentManager.ShareChannel = true;
deploymentManager.CommandRuntime = new MockCommandRuntime();
deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName);
resultMessage = ((MockCommandRuntime)deploymentManager.CommandRuntime).WarningStream[0];
Assert.IsFalse(statusUpdated);
Assert.IsTrue(resultMessage.Contains(expectedMessage));
Assert.IsTrue(((MockCommandRuntime)deploymentManager.CommandRuntime).OutputPipeline.Count.Equals(0));
}
}
示例4: TestCreateStorageServiceWithPublish
public void TestCreateStorageServiceWithPublish()
{
using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true })
{
// Setup
string rootPath = files.CreateNewService(serviceName);
files.CreateAzureSdkDirectoryAndImportPublishSettings();
AzureService cloudServiceProject = new AzureService(rootPath, null);
cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath);
cloudService.Deployments.Add(deployment);
serviceManagementChannelMock.Setup(f => f.EndGetStorageService(It.IsAny<IAsyncResult>()))
.Callback(() => serviceManagementChannelMock.Setup(f => f.EndGetStorageService(
It.IsAny<IAsyncResult>()))
.Returns(storageService))
.Throws(new EndpointNotFoundException());
ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US"));
serviceManagementChannelMock.Verify(f => f.BeginCreateStorageService(
subscription.SubscriptionId,
It.IsAny<CreateStorageServiceInput>(),
null,
null), Times.Once());
}
}
示例5: SetAzureInstancesProcessTestsEmptyRoleNameFail
public void SetAzureInstancesProcessTestsEmptyRoleNameFail()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
AzureService service = new AzureService(files.RootPath, serviceName, null);
Testing.AssertThrows<ArgumentException>(() => service.SetRoleInstances(service.Paths, string.Empty, 10), string.Format(Resources.InvalidOrEmptyArgumentMessage, Resources.RoleName));
}
}
示例6: SetAzureInstancesProcessNegativeRoleInstanceFail
public void SetAzureInstancesProcessNegativeRoleInstanceFail()
{
string roleName = "WebRole1";
using (FileSystemHelper files = new FileSystemHelper(this))
{
AzureService service = new AzureService(files.RootPath, serviceName, null);
Testing.AssertThrows<ArgumentException>(() => service.SetRoleInstances(service.Paths, roleName, -1), string.Format(Resources.InvalidInstancesCount, roleName));
}
}
示例7: GetNextPortAllNull
public void GetNextPortAllNull()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
int expectedPort = int.Parse(Resources.DefaultWebPort);
AzureService service = new AzureService(files.RootPath, serviceName, null);
int nextPort = service.Components.GetNextPort();
Assert.AreEqual<int>(expectedPort, nextPort);
}
}
示例8: GetNextPortNodeWebRoleNull
public void GetNextPortNodeWebRoleNull()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
int expectedPort = int.Parse(Resources.DefaultPort);
AzureService service = new AzureService(files.RootPath, serviceName, null);
service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
service = new AzureService(service.Paths.RootPath, null);
int nextPort = service.Components.GetNextPort();
Assert.AreEqual<int>(expectedPort, nextPort);
}
}
示例9: CreateLocalPackageWithNodeWorkerRoleTest
public void CreateLocalPackageWithNodeWorkerRoleTest()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string standardOutput;
string standardError;
AzureService service = new AzureService(files.RootPath, serviceName, null);
service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
service.CreatePackage(DevEnv.Local, out standardOutput, out standardError);
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole));
}
}
示例10: StopAzureEmulatorProcess
public void StopAzureEmulatorProcess()
{
string standardOutput;
string standardError;
AzureService service = new AzureService();
WriteVerbose(Resources.StopEmulatorMessage);
service.StopEmulator(out standardOutput, out standardError);
WriteVerbose(Resources.StoppedEmulatorMessage);
if (PassThru.IsPresent)
{
WriteObject(true);
}
}
示例11: NewAzureServiceProcess
internal AzureService NewAzureServiceProcess(string parentDirectory, string serviceName)
{
// Create scaffolding structure
//
AzureService newService = new AzureService(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;
}
示例12: TestStopAzureService
public void TestStopAzureService()
{
stopServiceCmdlet.ServiceName = serviceName;
stopServiceCmdlet.Slot = slot;
cloudServiceClientMock.Setup(f => f.StopCloudService(serviceName, slot));
using (FileSystemHelper files = new FileSystemHelper(this))
{
files.CreateAzureSdkDirectoryAndImportPublishSettings();
AzureService service = new AzureService(files.RootPath, serviceName, null);
stopServiceCmdlet.ExecuteCmdlet();
Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count);
cloudServiceClientMock.Verify(f => f.StopCloudService(serviceName, slot), Times.Once());
}
}
示例13: DisableRemoteDesktop
public void DisableRemoteDesktop()
{
AzureService service = new AzureService(General.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);
}
}
示例14: AddAzureCacheWorkerRoleProcess
public WorkerRole AddAzureCacheWorkerRoleProcess(string workerRoleName, int instances, string rootPath)
{
// Create cache worker role.
AzureService azureService = new AzureService(rootPath, null);
RoleInfo nodeWorkerRole = azureService.AddWorkerRole(Path.Combine(Resources.GeneralScaffolding, RoleType.WorkerRole.ToString()), workerRoleName, instances);
azureService = CachingConfigurationFactoryMethod(rootPath, nodeWorkerRole, new AzureTool().AzureSdkVersion);
azureService.Components.Save(azureService.Paths);
WorkerRole cacheWorkerRole = azureService.Components.GetWorkerRole(nodeWorkerRole.Name);
// Write output
SafeWriteOutputPSObject(
cacheWorkerRole.GetType().FullName,
Parameters.CacheWorkerRoleName, nodeWorkerRole.Name,
Parameters.Instances, nodeWorkerRole.InstanceCount
);
return azureService.Components.GetWorkerRole(workerRoleName);
}
示例15: SetAzureVMSizeProcessTestsCaseInsensitiveVMSizeSize
public void SetAzureVMSizeProcessTestsCaseInsensitiveVMSizeSize()
{
string newRoleVMSize = "ExTraLaRge";
using (FileSystemHelper files = new FileSystemHelper(this))
{
AzureService service = new AzureService(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 AzureService(service.Paths.RootPath, null);
Assert.AreEqual<string>(newRoleVMSize.ToLower(), service.Components.Definition.WebRole[0].vmsize.ToString().ToLower());
Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count);
Assert.AreEqual<string>(roleName, roleSettings.name);
}
}