-
Notifications
You must be signed in to change notification settings - Fork 36
Getting Started
If you don't already have credentials, you'll need to get some:
Then, you'll need the gem.
gem install azure-armrest
At the moment, the azure-armrest gem requires a service account. That means you'll need a tenant ID, a client ID and a client key. Once you have those, you can create a configuration object like so.
# Or, require 'azure/armrest' - either one will work.
require 'azure-armrest'
# For versions older than 0.3.0 use Azure::Armrest::ArmrestService.configure
conf = Azure::Armrest::Configuration.new(
:tenant_id => "xxxxxxxxx",
:client_id => "yyyyyyyyy",
:client_key => "zzzzzzzzz",
:subscription_id => "abcd1234xyz"
)
Note that versions of this gem older than 0.3.0 did not obligate you to provide a subscription ID and would use the first enabled subscription ID it found for your credentials. In version 0.3.x, the subscription ID is both mandatory and validated internally. As of version 0.4.x, the subscription ID is optional within the Configuration constructor, but its presence is required for almost all Service classes.
You may also specify a :resource_group
identifier. If provided, all resource group based services will use that group for all methods by default. Otherwise, you must specify the resource group for most methods.
As of 0.5.0 you can also specify an :environment
to the constructor:
Now that you have a configuration object, you can pass it to the various "Service" classes. These are basically organized and modeled after the Azure REST API.
vms = Azure::Armrest::VirtualMachineService.new(conf)
sas = Azure::Armrest::StorageAccountService.new(conf)
You can specify an HTTP proxy in the configure method if necessary setting the :proxy
key in the Configuration.new
method. By default it will use your 'http_proxy' environment variable, if set.
Because storage account models make their own requests for blobs, tables and files, you may need to set the proxy on those objects separately. They also use your 'http_proxy' environment variable, if set.
If you've registered your app, but would rather use the CLI than the azure-armrest gem, you can use them to login like so:
az login --service-principal -u <app_id> -t <tenant_id> -p <client_key>
Where app_id
is the client id, and the client_key
was they key you created during the registration process. Alternatively, you may pass the dev URL that you registered when you created your application for the -u option.