本文整理汇总了C#中Microsoft.Azure.Common.Authentication.Models.AzureSubscription类的典型用法代码示例。如果您正苦于以下问题:C# AzureSubscription类的具体用法?C# AzureSubscription怎么用?C# AzureSubscription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AzureSubscription类属于Microsoft.Azure.Common.Authentication.Models命名空间,在下文中一共展示了AzureSubscription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsStorageServiceAvailable
public bool IsStorageServiceAvailable(AzureSubscription subscription, string name)
{
EnsureCloudServiceClientInitialized(subscription);
bool available = this.CloudServiceClient.CheckStorageServiceAvailability(name);
WriteObject(!available);
return available;
}
示例2: AzureSqlDatabaseAdapter
/// <summary>
/// Constructs a database adapter
/// </summary>
/// <param name="profile">The current azure profile</param>
/// <param name="subscription">The current azure subscription</param>
public AzureSqlDatabaseAdapter(AzureProfile Profile, AzureSubscription subscription)
{
this.Profile = Profile;
this._subscription = subscription;
Communicator = new AzureSqlDatabaseCommunicator(Profile, subscription);
ElasticPoolCommunicator = new AzureSqlElasticPoolCommunicator(Profile, subscription);
}
示例3: WebsitesClient
/// <summary>
/// Creates new WebsitesClient
/// </summary>
/// <param name="subscription">Subscription containing websites to manipulate</param>
/// <param name="logger">The logger action</param>
public WebsitesClient(AzureProfile profile, AzureSubscription subscription, Action<string> logger)
{
Logger = logger;
cloudServiceClient = new CloudServiceClient(profile, subscription, debugStream: logger);
WebsiteManagementClient = AzureSession.ClientFactory.CreateClient<WebSiteManagementClient>(profile, subscription, AzureEnvironment.Endpoint.ServiceManagement);
this.subscription = subscription;
}
示例4: DisableAzureWebsiteApplicationDiagnosticApplication
public void DisableAzureWebsiteApplicationDiagnosticApplication()
{
// Setup
websitesClientMock.Setup(f => f.DisableApplicationDiagnostic(
websiteName,
WebsiteDiagnosticOutput.FileSystem, null));
disableAzureWebsiteApplicationDiagnosticCommand = new DisableAzureWebsiteApplicationDiagnosticCommand()
{
CommandRuntime = commandRuntimeMock.Object,
Name = websiteName,
WebsitesClient = websitesClientMock.Object,
File = true,
};
currentProfile = new AzureProfile();
var subscription = new AzureSubscription{Id = new Guid(base.subscriptionId) };
subscription.Properties[AzureSubscription.Property.Default] = "True";
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;
// Test
disableAzureWebsiteApplicationDiagnosticCommand.ExecuteCmdlet();
// Assert
websitesClientMock.Verify(f => f.DisableApplicationDiagnostic(
websiteName,
WebsiteDiagnosticOutput.FileSystem, null), Times.Once());
commandRuntimeMock.Verify(f => f.WriteObject(true), Times.Never());
}
示例5: SetupEnvironment
/// <summary>
/// This overrides the default subscription and default account. This allows the
/// test to get the tenant id in the test.
/// </summary>
public void SetupEnvironment()
{
base.SetupEnvironment(AzureModule.AzureResourceManager);
TestEnvironment csmEnvironment = new CSMTestEnvironmentFactory().GetTestEnvironment();
if (csmEnvironment.SubscriptionId != null)
{
//Overwrite the default subscription and default account
//with ones using user ID and tenant ID from auth context
var user = GetUser(csmEnvironment);
var tenantId = GetTenantId(csmEnvironment);
// Existing test will not have a user or tenant id set
if (tenantId != null && user != null)
{
var testSubscription = new AzureSubscription()
{
Id = new Guid(csmEnvironment.SubscriptionId),
Name = AzureRmProfileProvider.Instance.Profile.Context.Subscription.Name,
Environment = AzureRmProfileProvider.Instance.Profile.Context.Subscription.Environment,
Account = user,
Properties = new Dictionary<AzureSubscription.Property, string>
{
{
AzureSubscription.Property.Default, "True"
},
{
AzureSubscription.Property.StorageAccount,
Environment.GetEnvironmentVariable("AZURE_STORAGE_ACCOUNT")
},
{
AzureSubscription.Property.Tenants, tenantId
},
}
};
var testAccount = new AzureAccount()
{
Id = user,
Type = AzureAccount.AccountType.User,
Properties = new Dictionary<AzureAccount.Property, string>
{
{
AzureAccount.Property.Subscriptions, csmEnvironment.SubscriptionId
},
}
};
AzureRmProfileProvider.Instance.Profile.Context.Subscription.Name = testSubscription.Name;
AzureRmProfileProvider.Instance.Profile.Context.Subscription.Id = testSubscription.Id;
AzureRmProfileProvider.Instance.Profile.Context.Subscription.Account = testSubscription.Account;
var environment = AzureRmProfileProvider.Instance.Profile.Environments[AzureRmProfileProvider.Instance.Profile.Context.Subscription.Environment];
environment.Endpoints[AzureEnvironment.Endpoint.Graph] = csmEnvironment.Endpoints.GraphUri.AbsoluteUri;
environment.Endpoints[AzureEnvironment.Endpoint.StorageEndpointSuffix] = "core.windows.net";
AzureRmProfileProvider.Instance.Profile.Save();
}
}
}
示例6: ListWebHostingPlansTest
public void ListWebHostingPlansTest()
{
// Setup
var clientMock = new Mock<IWebsitesClient>();
clientMock.Setup(c => c.ListWebSpaces())
.Returns(new[] {new WebSpace {Name = "webspace1"}, new WebSpace {Name = "webspace2"}});
clientMock.Setup(c => c.ListWebHostingPlans())
.Returns(new List<WebHostingPlan>
{
new WebHostingPlan {Name = "Plan1", WebSpace = "webspace1"},
new WebHostingPlan { Name = "Plan2", WebSpace = "webspace2" }
});
// Test
var command = new GetAzureWebHostingPlanCommand
{
CommandRuntime = new MockCommandRuntime(),
WebsitesClient = clientMock.Object
};
currentProfile = new AzureProfile();
var subscription = new AzureSubscription{Id = new Guid(subscriptionId) };
subscription.Properties[AzureSubscription.Property.Default] = "True";
currentProfile.Subscriptions[new Guid(subscriptionId)] = subscription;
command.ExecuteCmdlet();
var plans = System.Management.Automation.LanguagePrimitives.GetEnumerable(((MockCommandRuntime)command.CommandRuntime).OutputPipeline).Cast<WebHostingPlan>();
Assert.NotNull(plans);
Assert.Equal(2, plans.Count());
Assert.True(plans.Any(p => (p).Name.Equals("Plan1") && (p).WebSpace.Equals("webspace1")));
Assert.True(plans.Any(p => (p).Name.Equals("Plan2") && (p).WebSpace.Equals("webspace2")));
}
示例7: ProcessShowWebsiteTest
public void ProcessShowWebsiteTest()
{
// Setup
var mockClient = new Mock<IWebsitesClient>();
mockClient.Setup(c => c.GetWebsite("website1", null))
.Returns(new Site
{
Name = "website1",
WebSpace = "webspace1",
HostNames = new[] {"website1.cloudapp.com"}
});
// Test
ShowAzureWebsiteCommand showAzureWebsiteCommand = new ShowAzureWebsiteCommand
{
CommandRuntime = new MockCommandRuntime(),
Name = "website1",
WebsitesClient = mockClient.Object
};
currentProfile = new AzureSMProfile();
var subscription = new AzureSubscription{Id = new Guid(base.subscriptionId) };
subscription.Properties[AzureSubscription.Property.Default] = "True";
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;
// Show existing website
showAzureWebsiteCommand.ExecuteCmdlet();
}
示例8: RestartsWebsiteSlot
public void RestartsWebsiteSlot()
{
// Setup
const string websiteName = "website1";
const string slot = "staging";
Mock<IWebsitesClient> websitesClientMock = new Mock<IWebsitesClient>();
websitesClientMock.Setup(f => f.RestartWebsite(websiteName, slot));
// Test
RestartAzureWebsiteCommand restartAzureWebsiteCommand = new RestartAzureWebsiteCommand()
{
CommandRuntime = new MockCommandRuntime(),
Name = websiteName,
WebsitesClient = websitesClientMock.Object,
Slot = slot
};
currentProfile = new AzureSMProfile();
var subscription = new AzureSubscription{Id = new Guid(base.subscriptionId) };
subscription.Properties[AzureSubscription.Property.Default] = "True";
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;
restartAzureWebsiteCommand.ExecuteCmdlet();
websitesClientMock.Verify(f => f.RestartWebsite(websiteName, slot), Times.Once());
}
示例9: GetCurrentSubscription
public static AzureSubscription GetCurrentSubscription()
{
string certificateThumbprint1 = "jb245f1d1257fw27dfc402e9ecde37e400g0176r";
var newSubscription = new AzureSubscription()
{
Id = IntegrationTestBase.TestCredentials.SubscriptionId,
// Use fake certificate thumbprint
Account = certificateThumbprint1,
Environment = "AzureCloud"
};
newSubscription.Properties[AzureSubscription.Property.Default] = "True";
ProfileClient profileClient = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
profileClient.Profile.Accounts[certificateThumbprint1] =
new AzureAccount()
{
Id = certificateThumbprint1,
Type = AzureAccount.AccountType.Certificate
};
profileClient.Profile.Subscriptions[newSubscription.Id] = newSubscription;
profileClient.Profile.Save();
return profileClient.Profile.Subscriptions[newSubscription.Id];
}
示例10: ExecuteCmdlet
public override void ExecuteCmdlet()
{
switch (ParameterSetName)
{
case "ByName":
IEnumerable<AzureSubscription> subscriptions = new AzureSubscription[0];
if (Profile.Context != null && Profile.Context.Environment != null)
{
subscriptions = ProfileClient.RefreshSubscriptions(Profile.Context.Environment)
.Where(
s =>
SubscriptionName == null ||
s.Name.Equals(SubscriptionName, StringComparison.InvariantCultureIgnoreCase));
}
WriteSubscriptions(subscriptions);
break;
case "ById":
WriteSubscriptions(ProfileClient.GetSubscription(new Guid(SubscriptionId)));
break;
case "Default":
GetDefault();
break;
case "Current":
GetCurrent();
break;
}
}
示例11: CreateAzureSMProfile
public static AzureSMProfile CreateAzureSMProfile(string storageAccount)
{
var profile = new AzureSMProfile();
var client = new ProfileClient(profile);
var tenantId = Guid.NewGuid();
var subscriptionId = Guid.NewGuid();
var account = new AzureAccount
{
Id = "[email protected]",
Type = AzureAccount.AccountType.User
};
account.SetProperty(AzureAccount.Property.Tenants, tenantId.ToString());
account.SetProperty(AzureAccount.Property.Subscriptions, subscriptionId.ToString());
var subscription = new AzureSubscription()
{
Id = subscriptionId,
Name = "Test Subscription 1",
Environment = EnvironmentName.AzureCloud,
Account = account.Id,
};
subscription.SetProperty(AzureSubscription.Property.Tenants, tenantId.ToString());
subscription.SetProperty(AzureSubscription.Property.StorageAccount, storageAccount);
client.AddOrSetAccount(account);
client.AddOrSetSubscription(subscription);
client.SetSubscriptionAsDefault(subscriptionId, account.Id);
return profile;
}
示例12: SwitchesSlots
public void SwitchesSlots()
{
// Setup
var mockClient = new Mock<IWebsitesClient>();
string slot1 = WebsiteSlotName.Production.ToString();
string slot2 = "staging";
mockClient.Setup(c => c.GetWebsiteSlots("website1"))
.Returns(new List<Site> {
new Site { Name = "website1", WebSpace = "webspace1" },
new Site { Name = "website1(staging)", WebSpace = "webspace1" }
});
mockClient.Setup(f => f.GetSlotName("website1")).Returns(slot1);
mockClient.Setup(f => f.GetSlotName("website1(staging)")).Returns(slot2);
mockClient.Setup(f => f.SwitchSlots("webspace1", "website1(staging)", slot1, slot2)).Verifiable();
mockClient.Setup(f => f.GetWebsiteNameFromFullName("website1")).Returns("website1");
// Test
SwitchAzureWebsiteSlotCommand switchAzureWebsiteCommand = new SwitchAzureWebsiteSlotCommand
{
CommandRuntime = new MockCommandRuntime(),
WebsitesClient = mockClient.Object,
Name = "website1",
Force = true
};
currentProfile = new AzureSMProfile();
var subscription = new AzureSubscription { Id = new Guid(base.subscriptionId) };
subscription.Properties[AzureSubscription.Property.Default] = "True";
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;
// Switch existing website
switchAzureWebsiteCommand.ExecuteCmdlet();
mockClient.Verify(c => c.SwitchSlots("webspace1", "website1", slot1, slot2), Times.Once());
}
示例13: AutomationClient
public AutomationClient(AzureSubscription subscription,
AutomationManagement.IAutomationManagementClient automationManagementClient)
{
Requires.Argument("automationManagementClient", automationManagementClient).NotNull();
this.Subscription = subscription;
this.automationManagementClient = automationManagementClient;
}
示例14: AzureSqlDatabaseReplicationAdapter
/// <summary>
/// Constructs a database adapter
/// </summary>
/// <param name="profile">The current azure profile</param>
/// <param name="subscription">The current azure subscription</param>
public AzureSqlDatabaseReplicationAdapter(AzureProfile Profile, AzureSubscription subscription)
{
this.Profile = Profile;
this._subscription = subscription;
ReplicationCommunicator = new AzureSqlDatabaseReplicationCommunicator(Profile, subscription);
DatabaseCommunicator = new AzureSqlDatabaseCommunicator(Profile, subscription);
ServerCommunicator = new AzureSqlServerCommunicator(Profile, subscription);
}
示例15: ValidateSubscription
/// <summary>
/// Validates that the given subscription is valid.
/// </summary>
/// <param name="subscription">The <see cref="AzureSubscription"/> to validate.</param>
public static void ValidateSubscription(AzureSubscription subscription)
{
if (subscription == null)
{
throw new ArgumentException(
Common.Properties.Resources.InvalidDefaultSubscription);
}
}