Created
October 19, 2018 18:31
-
-
Save siennathesane/f1e605227f403f63b2c6c3d773e45177 to your computer and use it in GitHub Desktop.
Short script to test whether an Azure region has availability zone support.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'azure_mgmt_compute' | |
| Compute = Azure::Compute::Profiles::Latest::Mgmt | |
| def generate_client | |
| subscription_id = ENV['AZURE_SUBSCRIPTION_ID'] # your Azure Subscription Id | |
| provider = MsRestAzure::ApplicationTokenProvider.new( | |
| ENV['AZURE_TENANT_ID'], | |
| ENV['AZURE_CLIENT_ID'], | |
| ENV['AZURE_CLIENT_SECRET']) | |
| credentials = MsRest::TokenCredentials.new(provider) | |
| options = { | |
| credentials: credentials, | |
| subscription_id: subscription_id | |
| } | |
| return compute_client = Compute::Client.new(options) | |
| end | |
| def has_az_availability(compute_client, region) | |
| skus_res = compute_client.resource_skus.list() | |
| zones_number = skus_res.select{|x| x.name == "Standard_DS1_v2"}.select{|x| x.locations.include? region}[0].location_info[0].zones.size | |
| return zones_number != 0 | |
| end | |
| if $0 == __FILE__ | |
| region == "eastus2" | |
| has_az_availability(generate_client, region) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment