F5Networks / f5-cloud-libs-azure

Azure specific implementations for f5-cloud-libs
Apache License 2.0
6 stars 1 forks source link

support for AzureEnvironments #1

Open chen23 opened 6 years ago

chen23 commented 6 years ago

The templates are currently set to use the default Azure environment. To support Azure Environments scripts will need to support Azure Environments. This includes things like "storageUri" in the ARM template.

Example for failoverProvider.js

*** scripts/failoverProvider.js 2017-11-15 05:52:53.000000000 +0000
--- scripts/failoverProvider.js.orig    2017-10-02 22:13:35.000000000 +0000
***************
*** 23,35 ****
  var resourceGroup = credentialsFile.resourceGroup;

  var msRestAzure = require('ms-rest-azure');
! var AzureEnvironment = require('ms-rest-azure/lib/azureEnvironment');
! var environment = AzureEnvironment.AzureUSGovernment;
! var options = { environment: environment };
! var credentials = new msRestAzure.ApplicationTokenCredentials(clientId, tenantId, secret, options);

  var networkManagementClient = require('azure-arm-network');
! var networkClient = new networkManagementClient(credentials, subscriptionId, environment.resourceManagerEndpointUrl);

  if (fs.existsSync('/config/cloud/managedRoutes')) {
      var routeFilter = fs.readFileSync('/config/cloud/managedRoutes', 'utf8').replace(/(\r\n|\n|\r)/gm,"").split(',');
--- 23,32 ----
  var resourceGroup = credentialsFile.resourceGroup;

  var msRestAzure = require('ms-rest-azure');
! var credentials = new msRestAzure.ApplicationTokenCredentials(clientId, tenantId, secret);

  var networkManagementClient = require('azure-arm-network');
! var networkClient = new networkManagementClient(credentials, subscriptionId);

  if (fs.existsSync('/config/cloud/managedRoutes')) {
      var routeFilter = fs.readFileSync('/config/cloud/managedRoutes', 'utf8').replace(/(\r\n|\n|\r)/gm,"").split(',');
chen23 commented 6 years ago

FYI, it looks like the metadata service can provide the location, but it is not accessible via the 169.254.169.254. Not sure whether it is supported to use the 168.63.129.16 address.

# using 168.63.129.16
[admin@chendevext1:Active:In Sync] ~ # curl --stderr /dev/null -H Metadata:true http://168.63.129.16/metadata/instance?api-version=2017-08-01|jq .compute.location
"usgovvirginia"
# trying to use documented IP
[admin@chendevext1:Active:In Sync] ~ # curl -m 3 -H Metadata:true http://169.254.169.254/metadata/instance?api-version=2017-08-01|jq .compute.location
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0curl: (28) Connection timed out after 3000 milliseconds
# unable to set management route
admin@(chendevext1)(cfg-sync In Sync)(Active)(/Common)(tmos)# create /sys management-route metadata network 169.254.169.254/32 gateway 172.16.0.1
01020062:3: IP Address 169.254.169.254 is invalid, link-local address not allowed.