Azure / azure-cli

Azure Command-Line Interface
MIT License
4.02k stars 2.99k forks source link

ResourceNotFound occurs if cluster is named differently than resource group #5180

Open ivansharamok opened 6 years ago

ivansharamok commented 6 years ago

When deploying SF cluster using ARM template, the error may occur at the end of deployment if cluster name is not the same as resource group name. I used ARM templates provided in repo service-fabric-api-management to deploy SF cluster. I specified clusterName parameter that is different from resource group name that I used to deploy the cluster. Each time I use cluster name that differs from the resource group, I get the following error message at the end of deployment:

urllib3.connectionpool : Starting new HTTPS connection (1): management.azure.com
urllib3.connectionpool : https://management.azure.com:443 "GET /subscriptions/1168fb9b-4abe-4ecb-b8a7-d70f324ee0ee/resourceGroups/sf-linux/providers/Microsoft.ServiceFabric/clusters/sf-linux?api-version=2016-09-01 HTTP/1.1" 404 153
msrest.http_logger : Request URL: 'https://management.azure.com/subscriptions/1168fb9b-4abe-4ecb-b8a7-d70f324ee0ee/resourceGroups/sf-linux/providers/Microsoft.ServiceFabric/clusters/sf-linux?api-version=2016-09-01'
msrest.http_logger : Request method: 'GET'
msrest.http_logger : Request headers:
msrest.http_logger :     'User-Agent': 'python/3.6.1 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 msrest_azure/0.4.17 azure-mgmt-servicefabric/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22'
msrest.http_logger :     'Accept-Encoding': 'gzip, deflate'
msrest.http_logger :     'Accept': 'application/json'
msrest.http_logger :     'Connection': 'keep-alive'
msrest.http_logger :     'Authorization': '*****'
msrest.http_logger :     'x-ms-client-request-id': 'a2de9d80-ec3d-11e7-8286-001c422c1884'
msrest.http_logger :     'CommandName': 'sf cluster create'
msrest.http_logger :     'Content-Type': 'application/json; charset=utf-8'
msrest.http_logger :     'accept-language': 'en-US'
msrest.http_logger : Request body:
msrest.http_logger : None
msrest.http_logger : Response status: 404
msrest.http_logger : Response headers:
msrest.http_logger :     'Cache-Control': 'no-cache'
msrest.http_logger :     'Pragma': 'no-cache'
msrest.http_logger :     'Content-Type': 'application/json; charset=utf-8'
msrest.http_logger :     'Expires': '-1'
msrest.http_logger :     'x-ms-failure-cause': 'gateway'
msrest.http_logger :     'x-ms-request-id': 'fdb228d8-6202-4139-9284-70ebe1b30100'
msrest.http_logger :     'x-ms-correlation-request-id': 'fdb228d8-6202-4139-9284-70ebe1b30100'
msrest.http_logger :     'x-ms-routing-request-id': 'CANADAEAST:20171229T022023Z:fdb228d8-6202-4139-9284-70ebe1b30100'
msrest.http_logger :     'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
msrest.http_logger :     'Date': 'Fri, 29 Dec 2017 02:20:22 GMT'
msrest.http_logger :     'Content-Length': '153'
msrest.http_logger : Response content:
msrest.http_logger : b'{"error":{"code":"ResourceNotFound","message":"The Resource \'Microsoft.ServiceFabric/clusters/sf-linux\' under resource group \'sf-linux\' was not found."}}'
msrest.exceptions : (ResourceNotFound) The Resource 'Microsoft.ServiceFabric/clusters/sf-linux' under resource group 'sf-linux' was not found.
(ResourceNotFound) The Resource 'Microsoft.ServiceFabric/clusters/sf-linux' under resource group 'sf-linux' was not found.
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\application.py", line 216, in execute
    result = expanded_arg.func(params)
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\commands\__init__.py", line 381, in __call__
    return self.handler(*args, **kwargs)
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\commands\__init__.py", line 640, in _execute_command
    raise client_exception
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\commands\__init__.py", line 630, in _execute_command
    reraise(*sys.exc_info())
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\six.py", line 693, in reraise
    raise value
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\commands\__init__.py", line 612, in _execute_command
    result = op(client, **kwargs) if client else op(**kwargs)
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\command_modules\servicefabric\custom.py", line 277, in new_cluster
    output_dict['cluster'] = client.get(resource_group_name, cluster_name)
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\mgmt\servicefabric\operations\clusters_operations.py", line 185, in get
    raise models.ErrorModelException(self._deserialize, response)
azure.mgmt.servicefabric.models.error_model.ErrorModelException: (ResourceNotFound) The Resource 'Microsoft.ServiceFabric/clusters/sf-linux' under resource group 'sf-linux' was not found.

It seems that at the end of cluster deployment CLI attempts to form a request to the cluster but it uses resource group name instead of the cluster name:

urllib3.connectionpool : https://management.azure.com:443 "GET /subscriptions/1168fb9b-4abe-4ecb-b8a7-d70f324ee0ee/resourceGroups/sf-linux/providers/Microsoft.ServiceFabric/clusters/sf-linux?api-version=2016-09-01 HTTP/1.1" 404 153
msrest.http_logger : Request URL: 'https://management.azure.com/subscriptions/1168fb9b-4abe-4ecb-b8a7-d70f324ee0ee/resourceGroups/sf-linux/providers/Microsoft.ServiceFabric/clusters/sf-linux?api-version=2016-09-01'

Environment summary

Install Method / Chocolatey
CLI version / azure-cli (2.0.22) with servicefabric (0.0.6)
OS version / Win10 Fall Creators Update
Shell Type / used both PowerShell and Bash on Windows
joergjo commented 6 years ago

This error can be avoided if you specify the --cluster-name parameter for az sf cluster create as well.

iharrington commented 5 years ago

I'm running into a similar issue, trying to add a VM Scale Set to a existing Service Fabric. Using az sf cluster node add -g resource_group -n cluster_name --number-of-nodes-to-add int --node-type 'type_name' It produces the same results. msrest.exceptions : Operation returned an invalid status code 'Not Found'

peterpogorski commented 5 years ago

Thank you for your feedback. We have added this to our backlog.

@tjprescott please assign this to @a-santamaria.

nishant-jain-94 commented 5 years ago

Had similar issue. Resolved after having same ClusterName and ResourceGroupName.

ghost commented 4 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @QingChenmsft, @vaishnavk, @juhacket.

mwesigwaguma commented 1 month ago

https://github.com/Azure/azure-cli/pull/29861