salt: Salt Cloud | [ERROR ] Error creating on Azure

Description of Issue/Question

Error when creating an instance on Azure with salt-cloud.

Setup

salt-cloud azure provider

# cat /etc/salt/cloud.providers.d/azure.provider.conf 
azure:
  driver: azure
  subscription_id: <my_subscription_id>
  certificate_path: /etc/salt/azure.pem
  minion:
    master: master.internal

salt-cloud azure profile

# cat /etc/salt/cloud.profiles.d/azure.profiles.conf 
azure-win:
  provider: azure
  image: '96316178b0644ae08bc4e037635ce104__HPC-Pack-2016-HN-5.0.5826.0-WS2012R2-ENU'
  size: Basic_A0
  location: 'West US 2'
  ssh_username: <user>
  ssh_password: <password>
  slot: production
  media_link: 'https://testresourcegroup7987.blob.core.windows.net/vhds'
  virtual_network_name: Test-ResourceGroup-vnet
  subnet_name: default

Steps to Reproduce Issue

I created 2 certificates:

-- first one used in salt-cloud
# openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout azure.pem -out azure.pem

-- second one uploaded to Azure via Classic Portal -> Settings -> Management Certificates -> Upload
# openssl x509 -inform pem -in azure.pem -outform der -out azure.cer

I tested it with “requests (2.7.0)”, “azure (1.0.2)” or “azure (1.0.3)”, as I see as deps required in the doc: https://docs.saltstack.com/en/latest/topics/cloud/azure.html

Microsoft Azure SDK for Python >= 1.0.2
The python-requests library, for Python < 2.7.9.

Then I found this: https://docs.saltstack.com/en/latest/ref/clouds/all/salt.cloud.clouds.azurearm.html#module-salt.cloud.clouds.azurearm

and - after upgrading salt to 2016.11.1 - I tested it again with “azure (2.0.0rc5)”, “azure-storage (0.32.0)”, “requests (2.7.0)” or “requests (2.12.5)”, as I see as deps required for this module:

Microsoft Azure SDK for Python >= 2.0rc5
Microsoft Azure Storage SDK for Python >= 0.32

I always receive the same error when I try to spin up an instance:

# salt-cloud  -p azure-win test-win -l debug
...
[INFO    ] Creating Cloud VM test-win
[DEBUG   ] vm_kwargs: {'system_config': <azure.servicemanagement.models.LinuxConfigurationSet object at 0x3c45a10>, 'deployment_slot': 'production', 'role_size': 'Basic_A0', 'deployment_name': 'test-win', 'virtual_network_name': 'Test-ResourceGroup-vnet', 'service_name': 'test-win', 'role_name': 'test-win', 'network_config': <azure.servicemanagement.models.ConfigurationSet object at 0x3c45950>, 'os_virtual_hard_disk': <azure.servicemanagement.models.OSVirtualHardDisk object at 0x3c45b10>, 'label': 'test-win'}
[DEBUG   ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc
[DEBUG   ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc
[DEBUG   ] Initializing new IPCClient for path: /var/run/salt/master/master_event_pull.ipc
[DEBUG   ] Sending event: tag = salt/cloud/test-win/requesting; data = {'_stamp': '2017-01-24T05:11:35.361633', 'service_kwargs': {'service_name': 'test-win', 'label': 'test-win', 'location': 'West US 2', 'description': 'test-win'}, 'event': 'requesting instance', 'vm_kwargs': {'deployment_slot': 'production', 'role_size': 'Basic_A0', 'deployment_name': 'test-win', 'virtual_network_name': 'Test-ResourceGroup-vnet', 'service_name': 'test-win', 'label': 'test-win', 'role_name': 'test-win'}}
[DEBUG   ] vm_kwargs: {'system_config': <azure.servicemanagement.models.LinuxConfigurationSet object at 0x3c45a10>, 'deployment_slot': 'production', 'role_size': 'Basic_A0', 'deployment_name': 'test-win', 'virtual_network_name': 'Test-ResourceGroup-vnet', 'service_name': 'test-win', 'role_name': 'test-win', 'network_config': <azure.servicemanagement.models.ConfigurationSet object at 0x3c45950>, 'os_virtual_hard_disk': <azure.servicemanagement.models.OSVirtualHardDisk object at 0x3c45b10>, 'label': 'test-win'}
[DEBUG   ] Cloud service already exists
[ERROR   ] Error creating test-win on Azure.

The Virtual Machine could not be created. If you are using an already existing Cloud Service, make sure you set up the `port` variable corresponding to the SSH port exists and that the port number is not already in use.
The following exception was thrown when trying to run the initial deployment: 
Not Found
<Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>ResourceNotFound</Code><Message>The hosted service does not exist.</Message></Error>
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/cloud/clouds/msazure.py", line 587, in create
    result = conn.create_virtual_machine_deployment(**vm_kwargs)
  File "/usr/lib/python2.7/site-packages/azure/servicemanagement/servicemanagementservice.py", line 1377, in create_virtual_machine_deployment
    async=True)
  File "/usr/lib/python2.7/site-packages/azure/servicemanagement/servicemanagementclient.py", line 382, in _perform_post
    response = self.perform_post(path, body, x_ms_version)
  File "/usr/lib/python2.7/site-packages/azure/servicemanagement/servicemanagementclient.py", line 224, in perform_post
    response = self._perform_request(request)
  File "/usr/lib/python2.7/site-packages/azure/servicemanagement/servicemanagementclient.py", line 339, in _perform_request
    return _management_error_handler(ex)
  File "/usr/lib/python2.7/site-packages/azure/servicemanagement/servicemanagementclient.py", line 417, in _management_error_handler
    return _general_error_handler(http_error)
  File "/usr/lib/python2.7/site-packages/azure/servicemanagement/_common_error.py", line 34, in _general_error_handler
    raise AzureHttpError(message, http_error.status)
AzureMissingResourceHttpError: Not Found
<Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>ResourceNotFound</Code><Message>The hosted service does not exist.</Message></Error>
Error: There was a profile error: Failed to deploy VM


Versions Report

# salt --versions-report
Salt Version:
           Salt: 2016.11.1
 
Dependency Versions:
           cffi: 1.9.1
       cherrypy: Not Installed
       dateutil: 2.6.0
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: 2.17
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.5 (default, Nov  6 2016, 00:28:07)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: 0.2.4
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: centos 7.3.1611 Core
        machine: x86_64
        release: 3.10.0-514.2.2.el7.x86_64
         system: Linux
        version: CentOS Linux 7.3.1611 Core

Any idea?

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 36 (23 by maintainers)

Most upvoted comments

@ritazh, I believe you are correct. Several of the packages you manually set the version for do NOT match the output I got, and I am also deploying on CentOS, CentOS7 to be specific.

azure==2.0.0 azure-batch==3.0.0 azure-common==1.1.8 azure-datalake-store==0.0.15 azure-graphrbac==0.30.0 azure-keyvault==0.3.6 azure-mgmt==1.0.0 azure-mgmt-authorization==0.30.0 azure-mgmt-batch==4.0.0 azure-mgmt-cdn==0.30.3 azure-mgmt-cognitiveservices==1.0.0 azure-mgmt-compute==1.0.0 azure-mgmt-containerregistry==0.2.1 azure-mgmt-datalake-analytics==0.1.6 azure-mgmt-datalake-nspkg==2.0.0 azure-mgmt-datalake-store==0.1.6 azure-mgmt-devtestlabs==2.0.0 azure-mgmt-dns==1.0.1 azure-mgmt-documentdb==0.1.3 azure-mgmt-iothub==0.2.2 azure-mgmt-keyvault==0.31.0 azure-mgmt-logic==2.1.0 azure-mgmt-monitor==0.2.1 azure-mgmt-network==1.0.0 azure-mgmt-nspkg==2.0.0 azure-mgmt-rdbms==0.1.0 azure-mgmt-redis==4.1.0 azure-mgmt-resource==1.1.0 azure-mgmt-scheduler==1.1.2 azure-mgmt-sql==0.5.3 azure-mgmt-storage==1.0.0 azure-mgmt-trafficmanager==0.30.0 azure-mgmt-web==0.32.0 azure-nspkg==2.0.0 azure-servicebus==0.21.1 azure-servicefabric==5.6.130 azure-servicemanagement-legacy==0.20.6 azure-storage==0.34.3 msrestazure==0.4.13

ditto here… salt-cloud is sort of useless on Azure with this bug.

jagguli & ccrivelli - me too facing the same issue - public ip’s are not assigned automatically. is there any work around ?

Bump … same issue

The Resource 'Microsoft.Network/publicIPAddresses/test-win-iface0-ip' under resource group '...' was not found.

Why is it trying to look for public ip ? public ip’s are not assigned automatically. I think the implementation is wrong.

@ccrivelli note that image has to be in different format Canonical|UbuntuServer|14.04.5-LTS|14.04.201612050 as per https://docs.saltstack.com/en/latest/topics/cloud/azurearm.html#image

Now, after several tests, I was able to login in this way… – provider config

# cat /etc/salt/cloud.providers.d/azure.provider.conf
azure:
  driver: azurearm
  subscription_id: <my_subrcription_id>

  username: <my_personal_username>
  password: <my_personal_password>
  location: 'West US 2'
  resource_group: Salt-RG

  # not optional
  network_resource_group: Salt-RG
  network: Salt-Vnet

~                                     

– I manually created via Azure Portal

ResourceGroup: Salt-RG
Vnet: Salt-Vnet

Now, when I try to spin up an instance with salt-cloud, I see the client logged in properly, then the Network Interface test-win-iface0 is automatically created (Http Response Code 200), but immediately after it goes in loop forever because The Resource 'Microsoft.Network/publicIPAddresses/test-win-iface0-ip' under resource group 'Salt-RG' was not found. (Http Response Code 404) and tried again infinitely.

– these are the debug logs for the Http request/response that’s going in loop

# salt-cloud  -p azure-win test-win -l debug
..
[DEBUG   ] Requesting url https://management.azure.com/subscriptions/<my_sub_id>/resourceGroups/Salt-RG/providers/Microsoft.Network/publicIPAddresses/test-win-iface0-ip?api-version=2016-03-30 using method GET.
[DEBUG   ] Supplying headers {'Content-Type': 'application/json; charset=utf-8', 'accept-language': 'en-US', 'x-ms-client-request-id': '...', u'Authorization': u'Bearer 
..'
} and data []
[DEBUG   ] Passing through key word arguments {'files': None, 'cookies': None, 'stream': True, 'verify': True, 'cert': None, 'timeout': 100, 'allow_redirects': True}.
[DEBUG   ] Request URL: 'https://management.azure.com/subscriptions/<my_sub_id>/resourceGroups/Salt-RG/providers/Microsoft.Network/publicIPAddresses/test-win-iface0-ip?api-version=2016-03-30'
[DEBUG   ] Request method: 'GET'
[DEBUG   ] Request headers:
[DEBUG   ]     'accept-language': 'en-US'
[DEBUG   ]     'Accept-Encoding': 'gzip, deflate'
[DEBUG   ]     'x-ms-client-request-id': '...'
[DEBUG   ]     'Accept': 'application/json'
[DEBUG   ]     'User-Agent': 'python/2.7.5 (Linux-3.10.0-514.2.2.el7.x86_64-x86_64-with-centos-7.3.1611-Core) requests/2.7.0 msrest/0.4.4 msrest_azure/0.4.7 networkmanagementclient/0.30.0rc5 Azure-SDK-For-Python SaltCloud/2016.11.1'
[DEBUG   ]     'Connection': 'keep-alive'
[DEBUG   ]     'Content-Type': 'application/json; charset=utf-8'
[DEBUG   ]     'Authorization': u'Bearer ..'
[DEBUG   ] Request body:
[DEBUG   ] None
[DEBUG   ] Received status: 404 for method 'GET'
[DEBUG   ] Is forced retry: False
[DEBUG   ] Response status: 404
[DEBUG   ] Response headers:
[DEBUG   ]     'content-length': '165'
[DEBUG   ]     'expires': '-1'
[DEBUG   ]     'x-ms-failure-cause': 'gateway'
[DEBUG   ]     'x-ms-request-id': '...'
[DEBUG   ]     'strict-transport-security': 'max-age=31536000; includeSubDomains'
[DEBUG   ]     'x-ms-correlation-request-id': '...'
[DEBUG   ]     'pragma': 'no-cache'
[DEBUG   ]     'cache-control': 'no-cache'
[DEBUG   ]     'date': 'Tue, 31 Jan 2017 04:29:42 GMT'
[DEBUG   ]     'x-ms-routing-request-id': 'EASTUS2:20170131T042942Z:...'
[DEBUG   ]     'content-type': 'application/json; charset=utf-8'
[DEBUG   ] Response content:
[DEBUG   ] {"error":{"code":"ResourceNotFound","message":"The Resource 'Microsoft.Network/publicIPAddresses/test-win-iface0-ip' under resource group 'Salt-RG' was not found."}}
[DEBUG   ] The Resource 'Microsoft.Network/publicIPAddresses/test-win-iface0-ip' under resource group 'Salt-RG' was not found.

Any thought?

Thanks