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

Azure Recovery Services Vaults Sku Attribute #647

Closed
bilal-naeem-confiz opened this issue Jan 11, 2017 · 2 comments
Closed

Azure Recovery Services Vaults Sku Attribute #647

bilal-naeem-confiz opened this issue Jan 11, 2017 · 2 comments
Assignees
Labels
ARM bug This issue requires a change to an existing behavior in the product in order to be resolved.
Milestone

Comments

@bilal-naeem-confiz
Copy link

Hi @vishrutshah

I am using the gem azure_mgmt_recovery_services to create a vault. L131 mentions that a Azure::ARM::RecoveryServices::Models::Vault object is also required to be passed to the create_or_update operation. So I created a Vault object and passed it to the create_or_update call. My script is the following

require 'azure_mgmt_recovery_services'

subscription_id = '########-####-####-####-############'
provider = MsRestAzure::ApplicationTokenProvider.new('########-####-####-####-############',
                                                     '########-####-####-####-############',
                                                     '############################################'
)
credentials = MsRest::TokenCredentials.new(provider)

recovery_services = Azure::ARM::RecoveryServices::RecoveryServicesClient.new(credentials)
recovery_services.subscription_id = subscription_id

vault = Azure::ARM::RecoveryServices::Models::Vault.new
vault.name = 'TestVault'
vault.location = 'eastus'
vault.properties = Azure::ARM::RecoveryServices::Models::VaultProperties.new

puts recovery_services.vaults.create_or_update('TestRG-RV', 'TestVault', vault).inspect

However, running this script results in the following error

/var/lib/gems/2.3.0/gems/azure_mgmt_recovery_services-0.8.0/lib/generated/azure_mgmt_recovery_services/vaults.rb:205:in `block in create_or_update_async': { (MsRestAzure::AzureOperationError)
  "message": "MsRestAzure::AzureOperationError: InvalidRestApiParameter: properties parameter is invalid.\r\nPlease provide a valid properties",
  "request": {
    "base_uri": "https://management.azure.com",
    "path_template": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}",
    "method": "put",
    "path_params": {
      "subscriptionId": "67f2116d-4ea2-4c6c-b20a-f92183dbe3cb",
      "resourceGroupName": "TestRG-RV",
      "vaultName": "TestVault"
    },
    "skip_encoding_path_params": null,
    "query_params": {
      "api-version": "2016-06-01"
    },
    "skip_encoding_query_params": null,
    "headers": {
      "Content-Type": "application/json; charset=utf-8",
      "accept-language": "en-US",
      "x-ms-client-request-id": "b6f19c31-958a-4def-b37f-3064b00bb2c8"
    },
    "body": "{\"location\":\"eastus\",\"properties\":{}}",
    "middlewares": [
      [
        "MsRest::RetryPolicyMiddleware",
        {
          "times": 3,
          "retry": 0.02
        }
      ],
      [
        "cookie_jar"
      ]
    ],
    "log": null
  },
  "response": {
    "body": "{\"error\":{\"code\":\"InvalidRestApiParameter\",\"message\":\"properties parameter is invalid.\\r\\nPlease provide a valid properties\",\"target\":null,\"details\":null,\"innerError\":null}}",
    "headers": {
      "cache-control": "no-cache",
      "pragma": "no-cache",
      "content-length": "173",
      "content-type": "application/json",
      "expires": "-1",
      "x-ms-request-id": "6b061cfd-697e-438b-8f9e-7816b1c772c7",
      "x-ms-client-request-id": "b6f19c31-958a-4def-b37f-3064b00bb2c8",
      "strict-transport-security": "max-age=31536000; includeSubDomains",
      "server": "Microsoft-IIS/8.0",
      "x-ms-ratelimit-remaining-subscription-writes": "1196",
      "x-ms-correlation-request-id": "6b061cfd-697e-438b-8f9e-7816b1c772c7",
      "x-ms-routing-request-id": "SOUTHEASTASIA:20170111T112859Z:6b061cfd-697e-438b-8f9e-7816b1c772c7",
      "date": "Wed, 11 Jan 2017 11:28:59 GMT",
      "connection": "close"
    },
    "status": 400
  }
}
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/promise.rb:501:in `block in on_fulfill'
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `block in synchronize'
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `synchronize'
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `synchronize'
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/executor/safe_task_executor.rb:19:in `execute'
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/promise.rb:531:in `block in realize'
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/executor/ruby_thread_pool_executor.rb:348:in `run_task'
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/executor/ruby_thread_pool_executor.rb:337:in `block (3 levels) in create_worker'
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `loop'
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `block (2 levels) in create_worker'
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `catch'
	from /var/lib/gems/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `block in create_worker'

Process finished with exit code 1

Upon further inspection, I found out that we also need to pass a Sku object to the Vault object as an attribute. However, the model for Vault does not specify any such attribute. This attribute is present when we retrieve a Vault object via the get request. This attribute needs to be set using the instance_variable_set method. Using this method and updating my script to the one below the issue was fixed and the vault was created.

require 'azure_mgmt_recovery_services'

subscription_id = '########-####-####-####-############'
provider = MsRestAzure::ApplicationTokenProvider.new('########-####-####-####-############',
                                                     '########-####-####-####-############',
                                                     '########-####-####-####-############'
)
credentials = MsRest::TokenCredentials.new(provider)

recovery_services = Azure::ARM::RecoveryServices::RecoveryServicesClient.new(credentials)
recovery_services.subscription_id = subscription_id

vault = Azure::ARM::RecoveryServices::Models::Vault.new
vault.name = 'TestVault'
vault.location = 'eastus'
sku = Azure::ARM::RecoveryServices::Models::Sku.new
sku.name = Azure::ARM::RecoveryServices::Models::SkuName::Standard

vault.instance_variable_set(:@sku, sku)
vault.properties = Azure::ARM::RecoveryServices::Models::VaultProperties.new

puts recovery_services.vaults.create_or_update('TestRG-RV', 'TestVault', vault).inspect

Kindly update your Azure::ARM::RecoveryServices::Models::Vault to include Sku as an attribute since it is required to create a RecoveryServices::Vault object.

Thanks

@bilal-naeem-confiz bilal-naeem-confiz changed the title Azure Recovery Services Vaults Azure Recovery Services Vaults Sku Attribute Jan 11, 2017
@bilal-naeem-confiz
Copy link
Author

Hi @vishrutshah

Is there any update on this issue?

@sarangan12
Copy link
Member

Azure/autorest#1769
#663

Code changes completed and merged to the master branch. Will be added to the next release (scheduled this week)

@vishrutshah vishrutshah added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Feb 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ARM bug This issue requires a change to an existing behavior in the product in order to be resolved.
Projects
None yet
Development

No branches or pull requests

4 participants