Skip to content
Daniel Berger edited this page Apr 6, 2018 · 7 revisions

What's an Environment?

An Azure "environment" is just a collection of endpoints that Azure uses to collect various pieces of information. The environment that you need depends on your credentials, which in turn can depend on your region. Or, in some cases, whether or not you work for a government entity.

Available Environments

The azure-armrest gem defines an Azure::Armrest::Environment class that you can use to create the environment that you need. As of azure-armrest 0.9.9, there are three available environments that are baked into the gem already.

  • Azure::Armrest::Environment::Public
  • Azure::Armrest::Environment::USGoverment
  • Azure::Armrest::Environment::Germany

By default the azure-armrest gem uses the "Public" environment. This is the most common environment, and so in most cases you will not need to set this explicitly.

Setting Your Environment

If you need to specify a different environment, you pass the :environment option to the Azure::Armrest::Configuration constructor like so:

config = Azure::Armrest::Configuration.new(
  :subscription_id => 'xxx',
  :tenant_id       => 'yyy',
  :client_id       => 'zzz',
  :client_key      => 'abc',
  :environment     => Azure::Armrest::Environment::Germany
)

Creating A Custom Environment

If you need to create a custom environment for your use, e.g. Azure Stack, you can create and assign one like so:

env = Azure::Armrest::Environment.new(
  :name                          => 'TestStack',
  :active_directory_authority    => 'https://login.windows.net/',
  :active_directory_resource_id  => 'https://management.poc.foo.com/abc123',
  :gallery_url                   => 'https://gallery.westus.foo.com/',
  :graph_url                     => 'https://graph.westus.foo.com/',
  :graph_api_version             => '1.6',
  :key_vault_dns_suffix          => 'vault.westus.foo.com',
  :key_vault_service_resource_id => 'https://vault.westus.foo.com/',
  :publish_settings_file_url     => 'https://management.westus.foo.com/publishsettings/index',
  :resource_manager_url          => 'https://management.westus.foo.com/',
  :service_management_url        => 'https://management.westus.foo.com/',
  :sql_database_dns_suffix       => 'westus.foo.com',
  :storage_suffix                => 'westus.foo.com',
  :traffic_manager_dns_suffix    => 'trafficmanager.net',
)


config = Azure::Armrest::Configuration.new(:environment => env, ...)

Not all of these endpoints are required, but at a minimum you must set the :name, :active_directory_authority, :resource_manager_url. Otherwise, an error will be raised.