本文整理汇总了C#中Microsoft.Azure.Common.Authentication.ProfileClient.GetEnvironment方法的典型用法代码示例。如果您正苦于以下问题:C# ProfileClient.GetEnvironment方法的具体用法?C# ProfileClient.GetEnvironment怎么用?C# ProfileClient.GetEnvironment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Azure.Common.Authentication.ProfileClient
的用法示例。
在下文中一共展示了ProfileClient.GetEnvironment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PublishSubscriptionToAzureSubscription
private static AzureSubscription PublishSubscriptionToAzureSubscription(
ProfileClient azureProfileClient,
PublishDataPublishProfile profile,
PublishDataPublishProfileSubscription s,
string environment)
{
var certificate = GetCertificate(profile, s);
if (string.IsNullOrEmpty(environment))
{
var azureEnvironment = azureProfileClient.GetEnvironment(environment, s.ServiceManagementUrl ?? profile.Url, null);
if (azureEnvironment != null)
{
environment = azureEnvironment.Name;
}
else
{
environment = EnvironmentName.AzureCloud;
}
}
return new AzureSubscription
{
Id = new Guid(s.Id),
Name = s.Name,
Environment = environment,
Account = certificate.Thumbprint
};
}
示例2: ExecuteCmdlet
/// <summary>
/// Executes the set subscription cmdlet operation.
/// </summary>
public override void ExecuteCmdlet()
{
AzureSubscription subscription = null;
if (!string.IsNullOrEmpty(SubscriptionId) && string.IsNullOrEmpty(SubscriptionName))
{
subscription = ProfileClient.GetSubscription(new Guid(SubscriptionId));
Environment = subscription.Environment;
}
else if (string.IsNullOrEmpty(SubscriptionId) && !string.IsNullOrEmpty(SubscriptionName))
{
subscription = ProfileClient.GetSubscription(SubscriptionName);
Environment = subscription.Environment;
}
else
{
subscription = new AzureSubscription();
subscription.Id = new Guid(SubscriptionId);
subscription.Name = SubscriptionName;
}
AzureEnvironment environment = ProfileClient.GetEnvironment(Environment, ServiceEndpoint, ResourceManagerEndpoint);
if (environment == null)
{
var profileClient = new ProfileClient(Profile);
environment = profileClient.GetEnvironment(Environment, ServiceEndpoint, ResourceManagerEndpoint);
}
if (environment == null)
{
throw new ArgumentException("ServiceEndpoint and ResourceManagerEndpoint values do not "+
"match existing environment. Please use Environment parameter.");
}
else
{
subscription.Environment = environment.Name;
}
if (ServiceEndpoint != null || ResourceManagerEndpoint != null)
{
WriteWarning("Please use Environment parameter to specify subscription environment. This "+
"warning will be converted into an error in the upcoming release.");
}
if (Certificate != null)
{
ProfileClient.ImportCertificate(Certificate);
subscription.Account = Certificate.Thumbprint;
AzureAccount account = new AzureAccount
{
Id = Certificate.Thumbprint,
Type = AzureAccount.AccountType.Certificate
};
account.SetOrAppendProperty(AzureAccount.Property.Subscriptions, subscription.Id.ToString());
ProfileClient.AddOrSetAccount(account);
if (subscription.Account == null)
{
subscription.Account = account.Id;
}
}
if (subscription.Account == null)
{
throw new ArgumentException("Certificate is required for creating a new subscription.");
}
if (!string.IsNullOrEmpty(CurrentStorageAccountName))
{
subscription.Properties[AzureSubscription.Property.StorageAccount] = CurrentStorageAccountName;
}
subscription = ProfileClient.AddOrSetSubscription(subscription);
if (PassThru)
{
WriteObject(subscription);
}
}