Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 2796673

Browse files
authored
Doc updates (#1054)
* Doc Updates * Updated * Added sample links * Updates * PR Comments * Minor change
1 parent f6a8e29 commit 2796673

File tree

2 files changed

+189
-2
lines changed

2 files changed

+189
-2
lines changed

ChangeLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 2017.10.13 - Azure ARM version 0.15.0
1+
## 2017.10.17 - Azure ARM version 0.15.0
22

33
* Each gem include multiple api-versions (namespace example: "Azure::Compute::Mgmt::V2017_03_30").
44
* Profiles are introduced:

README.md

Lines changed: 188 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11

2+
**NOTE**: With 0.15.0 version of Azure SDK, significant changes (Multiple API versions & Profiles) have been introduced.
3+
The details are available [here](#azure-multiple-api-versions--profiles)
4+
25
# Microsoft Azure SDK for Ruby - Resource Management (preview)
36
[![Build Status](https://api.travis-ci.org/Azure/azure-sdk-for-ruby.svg?branch=master)](https://api.travis-ci.org/Azure/azure-sdk-for-ruby) [![Code Climate](https://codeclimate.com/github/Azure/azure-sdk-for-ruby/badges/gpa.svg)](https://codeclimate.com/github/Azure/azure-sdk-for-ruby)
47

@@ -94,6 +97,190 @@ see [Developer’s guide to auth with Azure Resource Manager API](http://aka.ms/
9497
After creating the service principal, you should have three pieces of information, a client id (GUID), client secret
9598
(string) and tenant id (GUID) or domain name (string).
9699

100+
# Azure Multiple API versions & Profiles
101+
102+
With 0.15.0 of Azure SDK, multiple API versions and profiles are introduced. With these changes, each individual gem
103+
has multiple versions of the services and several profiles. The azure_sdk rollup gem also consists of several profiles. The following section provides details on the usage of multiple API versions and profiles.
104+
105+
## Why Multiple API versions?
106+
107+
Versions 0.14.0 and older, would have access to the latest versions of Azure services at the time of release. Each release up to 0.14.0, would include the latest available api-version of the services. There wasn't an option to use an older api-version of the service (except for using an older version of the sdk gem). With the introduction of multiple API versions per gem, any api-version available for the service can be explicitly targeted.
108+
109+
## What is a Profile?
110+
111+
A profile is a combination of different resource types with different versions from different services. Using a profile,
112+
will help you mix and match between various resource types.
113+
114+
## What to use?
115+
* If you would like to use the latest versions of **all** the services, then the recommendation is to use the **Latest** profile of the Azure SDK rollup gem.
116+
117+
* If you would like to use the services compatible with the **Azure Stack**, then the recommendation is to use the **V2017_03_09** profile of the Azure SDK rollup gem.
118+
119+
* If you would like to use the **latest** api-version of a service, then the recommendation is to use the **Latest** profile of the specific gem. For example, if you would like to use the latest api-version of compute service alone, use the Latest profile of compute gem.
120+
121+
* If you would like to use **specific** api-version of a service, then the recommendation is to use the **specific API** versions defined inside that gem.
122+
123+
Note: All the above options could be combined within the same application.
124+
125+
## Usage of azure_sdk gem
126+
127+
azure_sdk gem is a rollup of all the supported gems in the Ruby SDK. This gem consists of a **Latest** profile which supports the latest version of all services. it introduces a versioned profile **V2017_03_09** profile which is built for Azure Stack.
128+
129+
### Install
130+
131+
You can install the azure_sdk rollup gem with the following command:
132+
133+
```ruby
134+
gem install 'azure_sdk'
135+
```
136+
137+
### Existing Profiles
138+
139+
To start with, the azure_sdk rollup gem has two profiles.
140+
1. V2017_03_09 (Profile built for Azure Stack)
141+
2. Latest (Profile consists of Latest versions of all services)
142+
143+
You could choose the profile that you would like to use. If you would like to use the latest versions of **all** the services, then the recommendation is to use the **Latest** profile of the azure_sdk rollup gem.
144+
145+
If you would like to use the services compatible with the **Azure Stack**, then the recommendation is to use the **V2017_03_09** profile of the Azure SDK rollup gem.
146+
147+
### Usage
148+
149+
The following lines should be used to instantiate a profile client:
150+
151+
```ruby
152+
# Provide credentials
153+
provider = MsRestAzure::ApplicationTokenProvider.new(
154+
ENV['AZURE_TENANT_ID'],
155+
ENV['AZURE_CLIENT_ID'],
156+
ENV['AZURE_CLIENT_SECRET'])
157+
credentials = MsRest::TokenCredentials.new(provider)
158+
159+
options = {
160+
credentials: credentials,
161+
subscription_id: ENV['AZURE_SUBSCRIPTION_ID']
162+
}
163+
164+
# Target profile built for Azure Stack
165+
profile_client = Azure::Profiles::V2017_03_09::Mgmt::Client.new(options)
166+
```
167+
168+
The profile client could be used to access individual RPs:
169+
170+
```ruby
171+
# To access the operations associated with Compute
172+
profile_client.compute.virtual_machines.get 'RESOURCE_GROUP_NAME', 'VIRTUAL_MACHINE_NAME'
173+
174+
# Option 1: To access the models associated with Compute
175+
purchase_plan_obj = profile_client.compute.model_classes.purchase_plan.new
176+
177+
# Option 2: To access the models associated with Compute
178+
# Notice Namespace: Azure::Profiles::<Profile Name>::<Service Name>::Mgmt::Models::<Model Name>
179+
purchase_plan_obj = Azure::Profiles::V2017_03_09::Compute::Mgmt::Models::PurchasePlan.new
180+
181+
```
182+
183+
## Usage of Individual gem using Profiles
184+
185+
### Install
186+
187+
You can install the individual gems using gem install. For eg, to install azure_mgmt_compute, use the following command:
188+
189+
```ruby
190+
gem install 'azure_mgmt_compute'
191+
```
192+
### Usage
193+
194+
The following lines should be used to instantiate a profile client:
195+
196+
```ruby
197+
# Provide credentials
198+
provider = MsRestAzure::ApplicationTokenProvider.new(
199+
ENV['AZURE_TENANT_ID'],
200+
ENV['AZURE_CLIENT_ID'],
201+
ENV['AZURE_CLIENT_SECRET'])
202+
credentials = MsRest::TokenCredentials.new(provider)
203+
204+
options = {
205+
credentials: credentials,
206+
subscription_id: ENV['AZURE_SUBSCRIPTION_ID']
207+
}
208+
209+
# Target profile built for Latest Compute
210+
profile_client = Azure::Compute::Profiles::Latest::Mgmt::Client.new(options)
211+
```
212+
The profile client could be used to access operations and models:
213+
214+
```ruby
215+
# To access the operations associated with Compute
216+
profile_client.virtual_machines.get 'RESOURCE_GROUP_NAME', 'VIRTUAL_MACHINE_NAME'
217+
218+
# Option 1: To access the models associated with Compute
219+
purchase_plan_obj = profile_client.model_classes.purchase_plan.new
220+
221+
# Option 2: To access the models associated with Compute
222+
# Notice Namespace: Azure::<Service Name>::Profiles::<Profile Name>::Mgmt::Models::<Model Name>
223+
purchase_plan_obj = Azure::Compute::Profiles::Latest::Mgmt::Models::PurchasePlan.new
224+
225+
```
226+
227+
## Usage of Individual gem using using specific api-version
228+
229+
In the previous section, we used the profile associated with individual gem. In the current section, we could use the
230+
version directly.
231+
232+
### Install
233+
234+
You can install the individual gems using gem install. For eg, to install azure_mgmt_compute, use the following command:
235+
236+
```ruby
237+
gem install 'azure_mgmt_compute'
238+
```
239+
### Usage
240+
241+
The following lines should be used to instantiate a profile client:
242+
243+
```ruby
244+
# Provide credentials
245+
provider = MsRestAzure::ApplicationTokenProvider.new(
246+
ENV['AZURE_TENANT_ID'],
247+
ENV['AZURE_CLIENT_ID'],
248+
ENV['AZURE_CLIENT_SECRET'])
249+
credentials = MsRest::TokenCredentials.new(provider)
250+
251+
options = {
252+
credentials: credentials,
253+
subscription_id: ENV['AZURE_SUBSCRIPTION_ID']
254+
}
255+
256+
# Target client for 2016_03_30 version of Compute
257+
compute_client = Azure::Compute::Mgmt::V2016_03_30::ComputeManagementClient.new(credentials)
258+
compute_client.subscription_id = subscription_id
259+
```
260+
261+
The compute client could be used to access operations and models:
262+
263+
```ruby
264+
# To access the operations associated with Compute
265+
compute_client.virtual_machines.get 'RESOURCE_GROUP_NAME', 'VIRTUAL_MACHINE_NAME'
266+
267+
# To access the models associated with Compute
268+
# Notice Namespace: Azure::<Service Name>::Mgmt::<Version Name>::Models::<Model Name>
269+
purchase_plan_obj = Azure::Compute::Mgmt::V2016_03_30::Models::PurchasePlan.new
270+
271+
```
272+
273+
## Samples using Profiles
274+
275+
The following samples could be used as a reference for Profiles usage::
276+
277+
* [Compute MSI VM](https://github.com/Azure-Samples/compute-ruby-msi-vm)
278+
* [Resource Manager & Groups](https://github.com/Azure-Samples/resource-manager-ruby-resources-and-groups)
279+
* [Compute Manage VM](https://github.com/Azure-Samples/compute-ruby-manage-vm)
280+
* [Template Deployment](https://github.com/Azure-Samples/resource-manager-ruby-template-deployment)
281+
* [Traffic Manager Profiles](https://github.com/Azure-Samples/traffic-manager-ruby-manage-profiles)
282+
283+
97284
### Getting Started Samples
98285
The tests for the libraries should provide a good example of how to get started with the clients. You can also see the
99286
readme for each of the libraries [Compute](management/azure_mgmt_compute),
@@ -138,7 +325,7 @@ bundle install
138325
example:
139326
```bash
140327
cd ./management/azure_mgmt_compute
141-
rspec spec/virtual_machines_spec.rb
328+
rspec spec/2017-03-30/virtual_machines_spec.rb
142329
```
143330
**If vcr cassette exist then it'll replay the test otherwise it'll record it.**
144331

0 commit comments

Comments
 (0)