本文整理汇总了C#中Microsoft.WindowsAzure.SubscriptionCloudCredentials类的典型用法代码示例。如果您正苦于以下问题:C# SubscriptionCloudCredentials类的具体用法?C# SubscriptionCloudCredentials怎么用?C# SubscriptionCloudCredentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubscriptionCloudCredentials类属于Microsoft.WindowsAzure命名空间,在下文中一共展示了SubscriptionCloudCredentials类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetConfiguration
public XDocument GetConfiguration(SubscriptionCloudCredentials credentials, string serviceName, DeploymentSlot slot)
{
using (var client = CloudContext.Clients.CreateComputeManagementClient(credentials))
{
try
{
var response = client.Deployments.GetBySlot(serviceName, slot);
if (response.StatusCode != HttpStatusCode.OK)
{
throw new Exception(string.Format("Getting deployment by slot returned HTTP Status Code: {0}",
response.StatusCode));
}
return string.IsNullOrEmpty(response.Configuration)
? null
: XDocument.Parse(response.Configuration);
}
catch (CloudException cloudException)
{
Log.VerboseFormat("Getting deployments for service '{0}', slot {1}, returned:\n{2}", serviceName, slot.ToString(), cloudException.Message);
return null;
}
}
}
开发者ID:bjewell52,项目名称:Calamari,代码行数:25,代码来源:AzureCloudServiceConfigurationRetriever.cs
示例2: OnExecute
protected override async Task OnExecute(SubscriptionCloudCredentials credentials)
{
using (var client = CloudContext.Clients.CreateCloudServiceManagementClient(credentials))
{
await Console.WriteInfoLine(String.Format(
CultureInfo.CurrentCulture,
Strings.Scheduler_CsNewCommand_CreatingService,
Name));
if (!WhatIf)
{
await client.CloudServices.CreateAsync(
Name,
new CloudServiceCreateParameters()
{
Description = Description,
Email = Email,
GeoRegion = GeoRegion,
Label = Label
});
}
await Console.WriteInfoLine(String.Format(
CultureInfo.CurrentCulture,
Strings.Scheduler_CsNewCommand_CreatedService,
Name));
}
}
开发者ID:NuGet,项目名称:NuGet.Operations,代码行数:26,代码来源:NewServiceCommand.cs
示例3: GetMetricValue
static double GetMetricValue(SubscriptionCloudCredentials cred,
MetricsClient metricsClient,
string webSiteResourceId,
string metricName)
{
double requestCount = 0;
var metricValueResult = metricsClient.MetricValues.List(
webSiteResourceId,
new List<string> { metricName },
"",
TimeSpan.FromHours(1),
DateTime.UtcNow - TimeSpan.FromDays(1),
DateTime.UtcNow
);
var values = metricValueResult.MetricValueSetCollection;
foreach (var value in values.Value)
{
foreach (var total in value.MetricValues)
{
if (total.Total.HasValue)
requestCount += total.Total.Value;
}
}
return requestCount;
}
开发者ID:nzthiago,项目名称:AzureMetricsSdkCommandLineExample,代码行数:29,代码来源:Program.cs
示例4: Upload
public Uri Upload(SubscriptionCloudCredentials credentials, string storageAccountName, string packageFile, string uploadedFileName)
{
var cloudStorage =
new CloudStorageAccount(new StorageCredentials(storageAccountName, GetStorageAccountPrimaryKey(credentials, storageAccountName)), true);
var blobClient = cloudStorage.CreateCloudBlobClient();
var container = blobClient.GetContainerReference(OctopusPackagesContainerName);
container.CreateIfNotExists();
var permission = container.GetPermissions();
permission.PublicAccess = BlobContainerPublicAccessType.Off;
container.SetPermissions(permission);
var fileInfo = new FileInfo(packageFile);
var packageBlob = GetUniqueBlobName(uploadedFileName, fileInfo, container);
if (packageBlob.Exists())
{
Log.VerboseFormat("A blob named {0} already exists with the same length, so it will be used instead of uploading the new package.",
packageBlob.Name);
return packageBlob.Uri;
}
UploadBlobInChunks(fileInfo, packageBlob, blobClient);
Log.Info("Package upload complete");
return packageBlob.Uri;
}
开发者ID:bjewell52,项目名称:Calamari,代码行数:28,代码来源:AzurePackageUploader.cs
示例5: OnExecute
protected override async Task OnExecute(SubscriptionCloudCredentials credentials)
{
using (var client = CloudContext.Clients.CreateSchedulerManagementClient(credentials))
{
await Console.WriteInfoLine(Strings.Scheduler_ColDeleteCommand_DeletingCollection, CloudService, Name);
await client.JobCollections.DeleteAsync(CloudService, Name);
}
}
开发者ID:NuGet,项目名称:NuGet.Operations,代码行数:8,代码来源:DeleteColCommand.cs
示例6: GetSingleCollection
private async Task GetSingleCollection(SubscriptionCloudCredentials credentials)
{
using (var client = CloudContext.Clients.CreateSchedulerManagementClient(credentials))
{
await Console.WriteInfoLine(Strings.Scheduler_CollectionsCommand_GettingCollection, Name, CloudService);
var response = await client.JobCollections.GetAsync(CloudService, Name);
await Console.WriteObject(response);
}
}
开发者ID:NuGet,项目名称:NuGet.Operations,代码行数:9,代码来源:CollectionsCommand.cs
示例7: OnExecute
protected override Task OnExecute(SubscriptionCloudCredentials credentials)
{
if (String.IsNullOrEmpty(Name))
{
return GetAllCollections(credentials);
}
else
{
return GetSingleCollection(credentials);
}
}
开发者ID:NuGet,项目名称:NuGet.Operations,代码行数:11,代码来源:CollectionsCommand.cs
示例8: GetStorageAccountPrimaryKey
static string GetStorageAccountPrimaryKey(SubscriptionCloudCredentials credentials, string storageAccountName)
{
using (var cloudClient = CloudContext.Clients.CreateStorageManagementClient(credentials))
{
var getKeysResponse = cloudClient.StorageAccounts.GetKeys(storageAccountName);
if (getKeysResponse.StatusCode != HttpStatusCode.OK)
throw new Exception(string.Format("GetKeys for storage-account {0} returned HTTP status-code {1}", storageAccountName, getKeysResponse.StatusCode));
return getKeysResponse.PrimaryKey;
}
}
开发者ID:sergio,项目名称:Calamari,代码行数:12,代码来源:AzurePackageUploader.cs
示例9: OnExecute
protected override async Task OnExecute(SubscriptionCloudCredentials credentials)
{
using (var client = CloudContext.Clients.CreateCloudServiceManagementClient(credentials))
{
await Console.WriteInfoLine(Strings.Scheduler_CsListCommand_ListingAvailableServices);
var response = await client.CloudServices.ListAsync();
await Console.WriteTable(response, r => new
{
r.Name,
r.Label,
r.Description,
r.GeoRegion
});
}
}
开发者ID:NuGet,项目名称:NuGet.Operations,代码行数:15,代码来源:ServicesCommand.cs
示例10: OnExecute
protected override async Task OnExecute(SubscriptionCloudCredentials credentials)
{
// Get the datacenter
var dc = GetDatacenter(Datacenter ?? 0, required: true);
// Find the server
var server = dc.FindResource(ResourceTypes.SqlDb, Database.ToString());
if (server == null)
{
await Console.WriteErrorLine(
Strings.Db_DatabaseCommandBase_NoDatabaseInDatacenter,
Datacenter.Value,
ResourceTypes.SqlDb,
Database.ToString());
return;
}
var connStr = new SqlConnectionStringBuilder(server.Value);
string serverName = Utils.GetServerName(connStr.DataSource);
// Get the secret value
var secrets = await GetEnvironmentSecretStore(Session.CurrentEnvironment);
string secretName = "sqldb." + serverName + ":admin";
// Connect to Azure
using (var sql = CloudContext.Clients.CreateSqlManagementClient(credentials))
{
await Console.WriteInfoLine(Strings.Db_ApplyAdminPasswordCommand_ApplyingPassword, secretName, serverName);
if (!WhatIf)
{
var secret = await secrets.Read(new SecretName(secretName), "nucmd db applyadminpassword");
if (secret == null)
{
await Console.WriteErrorLine(Strings.Db_ApplyAdminPasswordCommand_NoPasswordInStore, serverName);
return;
}
await sql.Servers.ChangeAdministratorPasswordAsync(
serverName, new ServerChangeAdministratorPasswordParameters()
{
NewPassword = secret.Value
},
CancellationToken.None);
}
await Console.WriteInfoLine(Strings.Db_ApplyAdminPasswordCommand_AppliedPassword);
}
}
开发者ID:NuGet,项目名称:NuGet.Operations,代码行数:46,代码来源:ApplyAdminPasswordCommand.cs
示例11: OnExecute
protected override async Task OnExecute(SubscriptionCloudCredentials credentials)
{
using (var client = CloudContext.Clients.CreateCloudServiceManagementClient(credentials))
{
await Console.WriteInfoLine(String.Format(
CultureInfo.CurrentCulture,
Strings.Scheduler_CsDeleteCommand_DeletingService,
Name));
if (!WhatIf)
{
await client.CloudServices.DeleteAsync(Name);
}
await Console.WriteInfoLine(String.Format(
CultureInfo.CurrentCulture,
Strings.Scheduler_CsDeleteCommand_DeletedService,
Name));
}
}
开发者ID:NuGet,项目名称:NuGet.Operations,代码行数:18,代码来源:DeleteServiceCommand.cs
示例12: OnExecute
protected override async Task OnExecute(SubscriptionCloudCredentials credentials)
{
if((MaxRecurrenceFrequency.HasValue && !MinRecurrenceInterval.HasValue) ||
(MinRecurrenceInterval.HasValue && !MaxRecurrenceFrequency.HasValue)) {
await Console.WriteErrorLine(Strings.Scheduler_ColNewCommand_MaxRecurrenceIncomplete);
}
else {
JobCollectionMaxRecurrence maxRecurrence = null;
if(MaxRecurrenceFrequency != null) {
maxRecurrence = new JobCollectionMaxRecurrence()
{
Frequency = MaxRecurrenceFrequency.Value,
Interval = MinRecurrenceInterval.Value
};
}
using (var client = CloudContext.Clients.CreateSchedulerManagementClient(credentials))
{
await Console.WriteInfoLine(Strings.Scheduler_ColNewCommand_CreatingCollection, Name, CloudService);
if (!WhatIf)
{
await client.JobCollections.CreateAsync(
CloudService,
Name,
new JobCollectionCreateParameters()
{
Label = Label,
IntrinsicSettings = new JobCollectionIntrinsicSettings()
{
Plan = Plan,
Quota = new JobCollectionQuota()
{
MaxJobCount = MaxJobCount,
MaxJobOccurrence = MaxJobOccurrence,
MaxRecurrence = maxRecurrence
}
}
},
CancellationToken.None);
}
await Console.WriteInfoLine(Strings.Scheduler_ColNewCommand_CreatedCollection, Name, CloudService);
}
}
}
开发者ID:NuGetPrototypes,项目名称:NuCmd,代码行数:44,代码来源:NewColCommand.cs
示例13: GetAllCollections
private async Task GetAllCollections(SubscriptionCloudCredentials credentials)
{
using (var client = CloudContext.Clients.CreateCloudServiceManagementClient(credentials))
{
await Console.WriteInfoLine(Strings.Scheduler_CollectionsCommand_ListingCollections, CloudService);
var response = await client.CloudServices.GetAsync(CloudService);
await Console.WriteTable(response.Resources.Where(r =>
String.Equals(r.ResourceProviderNamespace, "scheduler", StringComparison.OrdinalIgnoreCase) &&
String.Equals(r.Type, "jobcollections", StringComparison.OrdinalIgnoreCase)),
r => new
{
r.Name,
r.State,
r.SubState,
r.Plan,
r.OutputItems
});
}
}
开发者ID:NuGet,项目名称:NuGet.Operations,代码行数:19,代码来源:CollectionsCommand.cs
示例14: OnExecute
protected override async Task OnExecute(SubscriptionCloudCredentials credentials)
{
if (ServiceUri == null)
{
await Console.WriteErrorLine(Strings.ParameterRequired, "SerivceUri");
}
else
{
using (var client = CloudContext.Clients.CreateSchedulerClient(credentials, CloudService, Collection))
{
var job = await client.Jobs.GetAsync(InstanceName, CancellationToken.None);
if (job == null)
{
await Console.WriteErrorLine(Strings.Scheduler_RefreshJobCommand_NoSuchJob, InstanceName);
}
else if (job.Job.Action.Type == JobActionType.StorageQueue || job.Job.Action.Request == null)
{
await Console.WriteErrorLine(Strings.Scheduler_RefreshJobCommand_NotAWorkServiceJob, InstanceName);
}
else
{
Uri old = job.Job.Action.Request.Uri;
job.Job.Action.Request.Uri = new Uri(ServiceUri, "work/invocations");
await Console.WriteInfoLine(
Strings.Scheduler_RefreshJobCommand_UpdatingUrl,
InstanceName,
old.AbsoluteUri,
job.Job.Action.Request.Uri.AbsoluteUri);
if (!WhatIf)
{
await client.Jobs.CreateOrUpdateAsync(InstanceName, new JobCreateOrUpdateParameters()
{
StartTime = job.Job.StartTime,
Action = job.Job.Action,
Recurrence = job.Job.Recurrence
}, CancellationToken.None);
}
}
}
}
}
开发者ID:NuGetPrototypes,项目名称:NuCmd,代码行数:41,代码来源:RefreshJobCommand.cs
示例15: OnExecute
protected override async Task OnExecute(SubscriptionCloudCredentials credentials)
{
using (var client = CloudContext.Clients.CreateSchedulerClient(credentials, CloudService, Collection))
{
await Console.WriteInfoLine(Strings.Scheduler_JobsCommand_ListingJobs, CloudService, Collection);
if (String.IsNullOrEmpty(Id))
{
var jobs = await client.Jobs.ListAsync(new JobListParameters(), CancellationToken.None);
await Console.WriteTable(jobs, r => new
{
r.Id,
r.State,
r.Status
});
}
else
{
var job = await client.Jobs.GetAsync(Id, CancellationToken.None);
await Console.WriteObject(job.Job);
}
}
}
开发者ID:NuGetPrototypes,项目名称:NuCmd,代码行数:22,代码来源:JobsCommand.cs
示例16: RemoveCloudService
private async static Task<OperationResponse> RemoveCloudService(SubscriptionCloudCredentials credentials,
string serviceName)
{
OperationResponse response;
Console.WriteLine("Removing Cloud Service '{0}'.", serviceName);
using (var client = new ComputeManagementClient(credentials))
{
response = await client.HostedServices.DeleteAllAsync(serviceName);
}
return response;
}
开发者ID:mkasek,项目名称:CodeMash2015-1,代码行数:14,代码来源:Program.cs
示例17: DeployCloudService
private async static Task<OperationResponse> DeployCloudService(SubscriptionCloudCredentials credentials, string storageAccountName,
string serviceName)
{
Console.WriteLine("Deploying to Cloud Service {0}", serviceName);
OperationResponse response = null;
string storageAccountKey = null;
using (var client = new StorageManagementClient(credentials))
{
var keys = await client.StorageAccounts.GetKeysAsync(storageAccountName);
storageAccountKey = keys.PrimaryKey;
}
string storageConnectionString =
string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", storageAccountName,
storageAccountKey);
CloudStorageAccount account = CloudStorageAccount.Parse(storageConnectionString);
CloudBlobClient blobClient = account.CreateCloudBlobClient();
CloudBlobContainer deploymentContainer = blobClient.GetContainerReference("maml-deployment");
await deploymentContainer.CreateIfNotExistsAsync();
CloudBlockBlob deploymentBlob = deploymentContainer.GetBlockBlobReference("AzureCloudService1.cspkg");
await deploymentBlob.UploadFromFileAsync(@"C:\Projects\Demos\AzureAutomationDemos\AzureAutomation\AzureCloudService1\bin\Release\app.publish\AzureCloudService1.cspkg", FileMode.Open);
using (var client = new ComputeManagementClient(credentials))
{
response = await client.Deployments.CreateAsync(serviceName,
DeploymentSlot.Production,
new DeploymentCreateParameters
{
Label = serviceName,
Name = serviceName + "Prod",
PackageUri = deploymentBlob.Uri,
Configuration = File.ReadAllText(@"C:\Projects\Demos\AzureAutomationDemos\AzureAutomation\AzureCloudService1\bin\Release\app.publish\ServiceConfiguration.Cloud.cscfg"),
StartDeployment = true
});
}
return response;
}
开发者ID:mkasek,项目名称:CodeMash2015-1,代码行数:43,代码来源:Program.cs
示例18: CreateCloudService
private async static Task<string> CreateCloudService(SubscriptionCloudCredentials credentials)
{
Console.WriteLine("Creating new Cloud Service . . .");
OperationResponse response;
string name = string.Format("{0}{1}", ResourceName, new Random().Next(1, 200));
using (var client = new ComputeManagementClient(credentials))
{
response = await client.HostedServices.CreateAsync(new HostedServiceCreateParameters
{
ServiceName = name,
Location = LocationNames.EastUS,
Label = string.Format("{0} Demo Service", ResourceName)
});
}
return name;
}
开发者ID:mkasek,项目名称:CodeMash2015-1,代码行数:20,代码来源:Program.cs
示例19: RemoveWebSite
private async static Task<OperationResponse> RemoveWebSite(SubscriptionCloudCredentials credentials, WebSite webSite)
{
OperationResponse response = null;
using (var client = new WebSiteManagementClient(credentials))
{
response = await client.WebSites.DeleteAsync(webSite.WebSpace, webSite.Name,
new WebSiteDeleteParameters
{
DeleteAllSlots = true,
DeleteEmptyServerFarm = true,
DeleteMetrics = true
});
}
if (response.StatusCode != HttpStatusCode.OK)
{
Console.WriteLine("Failed to delete website.");
}
else
{
Console.WriteLine("Deleted web site '{0}'.", webSite.Name);
}
return response;
}
开发者ID:mkasek,项目名称:CodeMash2015-1,代码行数:26,代码来源:Program.cs
示例20: CreateWebSite
private async static Task<WebSiteCreateResponse> CreateWebSite(SubscriptionCloudCredentials credentials)
{
Console.WriteLine("Creating new Azure Web Site . . .");
WebSiteCreateResponse response = null;
using (var client = new WebSiteManagementClient(credentials))
{
var webspaces = await client.WebSpaces.ListAsync();
var myWebSpace = webspaces.First(x => x.GeoRegion == LocationNames.EastUS);
var whp = new WebHostingPlanCreateParameters
{
Name = string.Format("{0}_whp", ResourceName.ToLower()),
NumberOfWorkers = 1,
SKU = SkuOptions.Free,
WorkerSize = WorkerSizeOptions.Small
};
var whpCreateResponse = await client.WebHostingPlans.CreateAsync(myWebSpace.Name,whp);
WebSiteCreateParameters siteCreateParameters = new WebSiteCreateParameters
{
Name = string.Format("{0}{1}", ResourceName, new Random().Next(1, 200)),
ServerFarm = whp.Name,
WebSpace = new WebSiteCreateParameters.WebSpaceDetails
{
GeoRegion = LocationNames.EastUS,
Name = myWebSpace.Name,
Plan = "VirtualDedicatedPlan"
}
};
response = await client.WebSites.CreateAsync(myWebSpace.Name, siteCreateParameters);
WebSiteGetPublishProfileResponse publishProfileResult =
await client.WebSites.GetPublishProfileAsync(myWebSpace.Name, siteCreateParameters.Name);
WebSiteGetPublishProfileResponse.PublishProfile profile =
publishProfileResult.PublishProfiles.First(x => x.MSDeploySite != null);
new WebDeployPublishingHelper(
profile.PublishUrl,
profile.MSDeploySite,
profile.UserName,
profile.UserPassword,
WebSitePath).PublishFolder();
}
return response;
}
开发者ID:mkasek,项目名称:CodeMash2015-1,代码行数:53,代码来源:Program.cs
注:本文中的Microsoft.WindowsAzure.SubscriptionCloudCredentials类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论