public async Async.Task <bool> HasComponents(string name) { var resourceGroup = _creds.GetBaseResourceGroup(); if (await GetVm(name) != null) { return(true); } if (await _ipOperations.GetPublicNic(resourceGroup, name) != null) { return(true); } if (await _ipOperations.GetIp(resourceGroup, name) != null) { return(true); } var disks = await _diskOperations.ListDisks(resourceGroup) .ToAsyncEnumerable() .Where(disk => disk.Data.Name.StartsWith(name)) .AnyAsync(); if (disks) { return(true); } return(false); }
public async Async.Task <MonitorSettings> GetMonitorSettings() { var token = GetToken(); var client = new OperationalInsightsManagementClient(new Rest.TokenCredentials(token.Token)) { SubscriptionId = _creds.GetSubscription() }; var customerId = (await client.Workspaces.ListByResourceGroupAsync(_creds.GetBaseResourceGroup())) .Select(w => w.CustomerId) .First(); var keys = await client.SharedKeys.GetSharedKeysAsync(_creds.GetBaseResourceGroup(), _config.OneFuzzMonitor); return(new MonitorSettings(customerId, keys.PrimarySharedKey)); }
public async Async.Task <MonitorSettings> GetMonitorSettings() { string[] scopes = { "https://management.azure.com/.default" }; var token = _creds.GetIdentity().GetToken(new TokenRequestContext(scopes)); var client = new OperationalInsightsManagementClient(new Rest.TokenCredentials(token.Token)) { SubscriptionId = _creds.GetSubscription() }; var customerId = (await client.Workspaces.ListByResourceGroupAsync(_creds.GetBaseResourceGroup())) .Select(w => w.CustomerId) .First(); var keys = await client.SharedKeys.GetSharedKeysAsync(_creds.GetBaseResourceGroup(), _config.OneFuzzMonitor); return(new MonitorSettings(customerId, keys.PrimarySharedKey)); }
public static async Async.Task <Network> Create(string region, ICreds creds, IConfigOperations configOperations, ISubnet subnet) { var group = creds.GetBaseResourceGroup(); var instanceConfig = await configOperations.Fetch(); var networkConfig = instanceConfig.NetworkConfig; // Network names will be calculated from the address_space/subnet // *except* if they are the original values. This allows backwards // compatibility to existing configs if you don't change the network // configs. string name; if (networkConfig.AddressSpace == NetworkConfig.Default.AddressSpace && networkConfig.Subnet == NetworkConfig.Default.Subnet) { name = region; } else { var networkId = Faithlife.Utility.GuidUtility.Create(NETWORK_GUID_NAMESPACE, string.Join("|", networkConfig.AddressSpace, networkConfig.Subnet), 5); name = $"{region}-{networkId}"; } return(new Network(region, group, name, networkConfig, subnet)); }
private VirtualMachineScaleSetResource GetVmssResource(Guid name) { var resourceGroup = _creds.GetBaseResourceGroup(); var id = VirtualMachineScaleSetResource.CreateResourceIdentifier(_creds.GetSubscription(), resourceGroup, name.ToString()); return(_creds.ArmClient.GetVirtualMachineScaleSetResource(id)); }
public async Task <HttpResponseData> GetBaseResourceGroup([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "testhooks/creds/baseResourceGroup")] HttpRequestData req) { _log.Info("Get base resource group"); var resp = req.CreateResponse(HttpStatusCode.OK); await resp.WriteStringAsync(_creds.GetBaseResourceGroup().ToString()); return(resp); }
public async Task <HttpResponseData> GetSubscription([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "testhooks/disks")] HttpRequestData req) { _log.Info("Get disk names"); var resp = req.CreateResponse(HttpStatusCode.OK); var diskNames = _diskOps.ListDisks(_creds.GetBaseResourceGroup()).ToList().Select(x => x.Data.Name); await resp.WriteAsJsonAsync(diskNames); return(resp); }