private static async Task DoWork() { //var logAction = new Action<string>(t => File.AppendAllText(@"c:\temp\maml.log", t)); //CloudContext.Configuration.Tracing.AddTracingInterceptor(new MyTraceInterceptor(logAction)); // Step 1 - Authenticate string token = await GetAuthorizationHeader(); TokenCloudCredentials tokenCloudCredentials = new TokenCloudCredentials(token); // Step 2 - Get a specific Azure subscription var subscription = await GetSubscription(tokenCloudCredentials, "MVP"); tokenCloudCredentials = new TokenCloudCredentials(subscription.SubscriptionId, tokenCloudCredentials.Token); // Step 3 - Create a storage account var storageAccountName = await CreateStorageAccount(tokenCloudCredentials); // Step 4 - Create a web site var webSiteResponse = await CreateWebSite(tokenCloudCredentials); // Step 5 - Clean up Console.WriteLine("Time to clean up! Press any key to delete all previously created resources."); Console.ReadLine(); var response = await RemoveStorageAccount(tokenCloudCredentials, storageAccountName); var deleteSiteResponse = await RemoveWebSite(tokenCloudCredentials, webSiteResponse.WebSite); Console.WriteLine("All done!"); Console.ReadLine(); }
public Program(ScheduledWebJobCreatorParameters parms) { // auth _credential = TokenCredentialHelper<MyPersonalConfiguration>.GetCredentials( new MyPersonalConfiguration(parms), parms.subscriptionId); // create the clients needed _cloudServiceManagementClient = CloudContext.Clients.CreateCloudServiceManagementClient(_credential); _webSiteMgmtClient = CloudContext.Clients.CreateWebSiteManagementClient(_credential); _schedulerMgmtClient = CloudContext.Clients.CreateSchedulerManagementClient(_credential); }
private async Task<string> GenerateResourceGroupName(string token, Repository repo, SubscriptionInfo[] subscriptions) { if (!string.IsNullOrEmpty(repo.RepositoryName)) { bool isAvailable = false; var creds = new TokenCloudCredentials(subscriptions.First().subscriptionId, token); var rdfeBaseUri = new Uri(Utils.GetRDFEUrl(Request.RequestUri.Host)); using (var webSiteMgmtClient = CloudContext.Clients.CreateWebSiteManagementClient(creds, rdfeBaseUri)) { // Make 3 attempts to get a random name (based on the repo name) for (int i = 0; i < 3; i++) { string resourceGroupName = GenerateRandomResourceGroupName(repo.RepositoryName); isAvailable = await IsSiteNameAvailable(webSiteMgmtClient, resourceGroupName); if (isAvailable) { return resourceGroupName; } } } } return null; }
public void TestClientInitialization() { var tokenCredentials = new TokenCloudCredentials("123", "abc"); var fakeClient = new WebSiteManagementClient(tokenCredentials); Assert.IsNotNull(fakeClient); }
void InitializeClients() { var rdfeToken = new TokenCloudCredentials(this.SubscriptionId, this.RdfeBearerToken); _computeClient = new Lazy<ComputeManagementClient>(() => new ComputeManagementClient(rdfeToken)); _storageClient = new Lazy<StorageManagementClient>(() => new StorageManagementClient(rdfeToken)); }
public async static void CreateResources( TokenCloudCredentials credential) { Console.WriteLine( "Creating the storage account. This may take a few minutes..."); var stResult = await CreateStorageAccount(credential); Console.WriteLine(stResult); }
public async static void CreateVM(TokenCloudCredentials credential) { Console.WriteLine("creating..."); var stResult = await CreateVirtualMachine(credential); Console.WriteLine(stResult); }
public AzureActiveDirectoryHelper(AzureActiveDirectoryConfig configuration) { var token = GetAuthorizationHeader(configuration); var cred = new TokenCloudCredentials(configuration.azureSubscriptionID, token); client = new WebSiteManagementClient(cred, APIENDPOINT); }