Add docs (#2)
* initial working version * cleanup/renaming * renaming * docs
This commit is contained in:
Родитель
d98d87657c
Коммит
d4e6d12fda
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
96
README.md
96
README.md
|
@ -1,4 +1,100 @@
|
|||
|
||||
# Dedicated Hosts Manager
|
||||
Azure Dedicated Host (DH) provides physical servers that host one or more Azure virtual machines; host-level isolation means that capacity is dedicated to your organization and servers are not shared with other customers. To use DH, users currently need to manage DH themselves - e.g. when to spin up or spin down Hosts, determine VM placement on Hosts, bin pack VMs compactly on Hosts to minimize Host usage and optimize for cost, or use another Host selection strategy, manage VM creation traffic burst scenarios, etc.
|
||||
|
||||
The Dedicated Hosts Manager library abstracts Host Management logic from users, and makes it easy for users to use DH. Users only need to specify the number and SKU of VMs that need to be allocated, and this library takes care of the rest. This library is packaged as an Azure Function that can be deployed in your subscription, and is easy to integrate with . The library is extensible and allows for customizing Host selection logic.
|
||||
|
||||
# Usage
|
||||
1. Deploy the Dedicated Hosts Manager function in your subscription and setup the below config.
|
||||
_Application settings:_
|
||||
```json
|
||||
{
|
||||
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
|
||||
"value": "App Insights Instrumentation Key",
|
||||
},
|
||||
{
|
||||
"name": "DhgCreateRetryCount",
|
||||
"value": "10",
|
||||
},
|
||||
{
|
||||
"name": "LockBlobPrefix",
|
||||
"value": "lock-",
|
||||
},
|
||||
{
|
||||
"name": "LockContainerName",
|
||||
"value": "dhm-sync",
|
||||
},
|
||||
{
|
||||
"name": "LockIntervalInSeconds",
|
||||
"value": "60",
|
||||
},
|
||||
{
|
||||
"name": "LockRetryCount",
|
||||
"value": "10",
|
||||
},
|
||||
{
|
||||
"name": "MaxIntervalToCheckForVmInSeconds",
|
||||
"value": "30",
|
||||
},
|
||||
{
|
||||
"name": "MinIntervalToCheckForVmInSeconds",
|
||||
"value": "20",
|
||||
},
|
||||
{
|
||||
"name": "RetryCountToCheckVmState",
|
||||
"value": "10",
|
||||
},
|
||||
{
|
||||
"name": "VmToHostMapping",
|
||||
"value": "{\"Standard_D2s_v3\":\"DSv3-Type1\",\"Standard_D4s_v3\":\"DSv3-Type1\",\"Standard_D8s_v3\":\"DSv3-Type1\",\"Standard_D16s_v3\":\"DSv3-Type1\",\"Standard_D32-8s_v3\":\"DSv3-Type1\",\"Standard_D32-16s_v3\":\"DSv3-Type1\",\"Standard_D32s_v3\":\"DSv3-Type1\",\"Standard_D48s_v3\":\"DSv3-Type1\",\"Standard_D64-16s_v3\":\"DSv3-Type1\",\"Standard_D64-32s_v3\":\"DSv3-Type1\",\"Standard_D64s_v3\":\"DSv3-Type1\",\"Standard_E2s_v3\":\"ESv3-Type1\",\"Standard_E4s_v3\":\"ESv3-Type1\",\"Standard_E8s_v3\":\"ESv3-Type1\",\"Standard_E16s_v3\":\"ESv3-Type1\",\"Standard_E32-8s_v3\":\"ESv3-Type1\",\"Standard_E32-16s_v3\":\"ESv3-Type1\",\"Standard_E32s_v3\":\"ESv3-Type1\",\"Standard_E48s_v3\":\"ESv3-Type1\",\"Standard_E64-16s_v3\":\"ESv3-Type1\",\"Standard_E64-32s_v3\":\"ESv3-Type1\",\"Standard_E64s_v3\":\"ESv3-Type1\",\"Standard_F2s_v3\":\"FSv2-Type2\",\"Standard_F4s_v3\":\"FSv2-Type2\",\"Standard_F8s_v3\":\"FSv2-Type2\",\"Standard_F16s_v3\":\"FSv2-Type2\",\"Standard_F32-8s_v3\":\"FSv2-Type2\",\"Standard_F32-16s_v3\":\"FSv2-Type2\",\"Standard_F32s_v3\":\"FSv2-Type2\",\"Standard_F48s_v3\":\"FSv2-Type2\",\"Standard_F64-16s_v3\":\"FSv2-Type2\",\"Standard_F64-32s_v3\":\"FSv2-Type2\",\"Standard_F64s_v3\":\"FSv2-Type2\"}",
|
||||
}
|
||||
|
||||
```
|
||||
_Connection strings:_
|
||||
```json
|
||||
{
|
||||
"name": "StorageConnectionString",
|
||||
"value": "Storage connection string",
|
||||
}
|
||||
```
|
||||
|
||||
2. Deploy the Dedicated Host Manager Test function in your subscription with the below config.
|
||||
|
||||
_Application settings:_
|
||||
```json
|
||||
{
|
||||
"name": "AuthEndpoint",
|
||||
"value": "https://login.microsoftonline.us/",
|
||||
},
|
||||
{
|
||||
"name": "AzureRmEndpoint",
|
||||
"value": "https://management.usgovcloudapi.net/",
|
||||
},
|
||||
{
|
||||
"name": "ClientId",
|
||||
"value": "Client ID from AAD service principal",
|
||||
},
|
||||
{
|
||||
"name": "FairfaxClientSecret",
|
||||
"value": "Client secret from AAD service principal",
|
||||
},
|
||||
{
|
||||
"name": "Location",
|
||||
"value": "usgovvirginia",
|
||||
},
|
||||
{
|
||||
"name": "SubscriptionId",
|
||||
"value": "Your subscription id",
|
||||
},
|
||||
{
|
||||
"name": "TenantId",
|
||||
"value": "Your tenant id",
|
||||
}
|
||||
```
|
||||
|
||||
3. Run the test Function to provision VMs on Dedicated Hosts
|
||||
|
||||
|
||||
# Contributing
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
|
|
|
@ -411,12 +411,12 @@ namespace DedicatedHostsManager
|
|||
throw new ArgumentException(nameof(location));
|
||||
}
|
||||
|
||||
var matchingHost = string.Empty;
|
||||
var matchingHostId = string.Empty;
|
||||
var innerLoopStopwatch = Stopwatch.StartNew();
|
||||
|
||||
while (string.IsNullOrEmpty(matchingHost))
|
||||
while (string.IsNullOrEmpty(matchingHostId))
|
||||
{
|
||||
matchingHost = await SelectHostFromHostGroup(
|
||||
matchingHostId = await SelectHostFromHostGroup(
|
||||
token,
|
||||
cloudName,
|
||||
tenantId,
|
||||
|
@ -425,7 +425,7 @@ namespace DedicatedHostsManager
|
|||
hostGroupName,
|
||||
requiredVmSize);
|
||||
|
||||
if (string.IsNullOrEmpty(matchingHost))
|
||||
if (string.IsNullOrEmpty(matchingHostId))
|
||||
{
|
||||
var lockRetryCount = int.Parse(_configuration["LockRetryCount"]);
|
||||
await Policy
|
||||
|
@ -441,7 +441,7 @@ namespace DedicatedHostsManager
|
|||
_logger.LogInformation($"About to lock");
|
||||
await _syncProvider.StartSerialRequests(_configuration["LockBlobName"]);
|
||||
|
||||
matchingHost = await SelectHostFromHostGroup(
|
||||
matchingHostId = await SelectHostFromHostGroup(
|
||||
token,
|
||||
cloudName,
|
||||
tenantId,
|
||||
|
@ -450,7 +450,7 @@ namespace DedicatedHostsManager
|
|||
hostGroupName,
|
||||
requiredVmSize);
|
||||
|
||||
if (string.IsNullOrEmpty(matchingHost))
|
||||
if (string.IsNullOrEmpty(matchingHostId))
|
||||
{
|
||||
_logger.LogInformation($"Creating a new host.");
|
||||
var vmToHostDictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(_configuration["VmToHostMapping"]);
|
||||
|
@ -478,7 +478,7 @@ namespace DedicatedHostsManager
|
|||
hostSku,
|
||||
location);
|
||||
|
||||
matchingHost = newDedicatedHostResponse.Body.Id;
|
||||
matchingHostId = newDedicatedHostResponse.Body.Id;
|
||||
_logger.LogMetric("DedicatedHostCreationCountMetric", 1);
|
||||
}
|
||||
}
|
||||
|
@ -497,15 +497,15 @@ namespace DedicatedHostsManager
|
|||
_logger.LogInformation($"Retry to find a host for {requiredVmSize}");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(matchingHost))
|
||||
if (string.IsNullOrEmpty(matchingHostId))
|
||||
{
|
||||
_logger.LogError($"Something went really wrong! Could not find a " +
|
||||
$"matching host for {requiredVmSize} within {innerLoopStopwatch.Elapsed.TotalSeconds} seconds. ");
|
||||
}
|
||||
|
||||
_logger.LogMetric("GetDedicatedHostTimeSecondsMetric", innerLoopStopwatch.Elapsed.TotalSeconds);
|
||||
_logger.LogInformation($"Inner loop time: Found a matching host {matchingHost} for {vmName} of {requiredVmSize} SKU after {innerLoopStopwatch.Elapsed.TotalSeconds} seconds");
|
||||
return matchingHost;
|
||||
_logger.LogInformation($"GetDedicatedHost: Took {innerLoopStopwatch.Elapsed.TotalSeconds} seconds to find a matching host {matchingHostId} for {vmName} of {requiredVmSize} SKU.");
|
||||
return matchingHostId;
|
||||
}
|
||||
|
||||
private async Task<string> SelectHostFromHostGroup(
|
||||
|
|
Загрузка…
Ссылка в новой задаче