Azure-cli: Azure Batch incorrect error when attempting to create a pool

Created on 3 Jan 2019  路  7Comments  路  Source: Azure/azure-cli

Describe the bug
When running az batch pool create without first running az batch account login and following error is returned:

az batch pool create --json-file ./pool.json --account-name batchaccounthere --account-endpoint batchaccounthere.uksouth.batch.azure.com --debug

returns:

az batch pool create: error: Batch account 'batchaccountnamehere' not found.

This error message is incorrect, the Batch Account does exist and if you run az batch account login then re-attempt the command then it will succeed.

To Reproduce

  1. Create a batch account and grab its name and endpoint
  2. Attempt to create a pool under it using the command above.
  3. Observe the incorrect error returned. az batch pool create: error: Batch account 'batchnamehere' not found. Full debug log, with redactions, bellow.
  4. Now run az batch account login for the same batch account and reattempt the process az batch pool create --json-file ./pool.json --debug. See that it succeeds this time.

Expected behavior
The error should either not occur, as the batch account exists, or if the login command is required it should instruct the user to run that command.

Environment summary
Ubuntu 18, apt based install,

Additional context

azure-cli (2.0.54)

acr (2.1.11)
acs (2.3.13)
advisor (2.0.0)
ams (0.3.1)
appservice (0.2.10)
backup (1.2.1)
batch (3.4.1)
batchai (0.4.5)
billing (0.2.0)
botservice (0.1.3)
cdn (0.2.0)
cloud (2.1.0)
cognitiveservices (0.2.4)
command-modules-nspkg (2.0.2)
configure (2.0.19)
consumption (0.4.1)
container (0.3.10)
core (2.0.54)
cosmosdb (0.2.6)
dla (0.2.3)
dls (0.1.7)
dms (0.1.1)
eventgrid (0.2.0)
eventhubs (0.3.2)
extension (0.2.3)
feedback (2.1.4)
find (0.2.13)
hdinsight (0.1.0)
interactive (0.4.1)
iot (0.3.4)
iotcentral (0.1.5)
keyvault (2.2.9)
lab (0.1.4)
maps (0.3.3)
monitor (0.2.7)
network (2.2.11)
nspkg (3.0.3)
policyinsights (0.1.0)
profile (2.1.2)
rdbms (0.3.5)
redis (0.3.2)
relay (0.1.2)
reservations (0.4.1)
resource (2.1.7)
role (2.2.0)
search (0.1.1)
servicebus (0.3.2)
servicefabric (0.1.10)
signalr (1.0.0)
sql (2.1.6)
storage (2.2.7)
telemetry (1.0.0)
vm (2.2.11)

Extensions:
interactive (0.4.1)

Python location '/opt/az/bin/python3'
Extensions directory '/home/lawrence/.azure/cliextensions'

Python (Linux) 3.6.5 (default, Dec 20 2018, 01:00:18) 
[GCC 7.3.0]

Legal docs and information: aka.ms/AzureCliLegal
az batch pool create --json-file ./pool.json --account-name batchaccountnamehere --account-endpoint batchaccountnamehere.uksouth.batch.azure.com --debug
Command arguments: ['batch', 'pool', 'create', '--json-file', './pool.json', '--account-name', 'batchaccountnamehere', '--account-endpoint', 'batchaccountnamehere.uksouth.batch.azure.com', '--debug']
Event: Cli.PreExecute []
Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7f6f3eb4ebf8>, <function OutputProducer.on_global_arguments at 0x7f6f3e8ed2f0>, <function CLIQuery.on_global_arguments at 0x7f6f3e8a2d90>]
Event: CommandInvoker.OnPreCommandTableCreate []
Installed command modules ['acr', 'acs', 'advisor', 'ams', 'appservice', 'backup', 'batch', 'batchai', 'billing', 'botservice', 'cdn', 'cloud', 'cognitiveservices', 'configure', 'consumption', 'container', 'cosmosdb', 'dla', 'dls', 'dms', 'eventgrid', 'eventhubs', 'extension', 'feedback', 'find', 'hdinsight', 'interactive', 'iot', 'iotcentral', 'keyvault', 'lab', 'maps', 'monitor', 'network', 'policyinsights', 'profile', 'rdbms', 'redis', 'relay', 'reservations', 'resource', 'role', 'search', 'servicebus', 'servicefabric', 'signalr', 'sql', 'storage', 'vm']
Loaded module 'acr' in 0.017 seconds.
Loaded module 'acs' in 0.002 seconds.
Loaded module 'advisor' in 0.001 seconds.
Event: CommandLoader.OnLoadCommandTable []
Loaded module 'ams' in 0.005 seconds.
Loaded module 'appservice' in 0.004 seconds.
Loaded module 'backup' in 0.002 seconds.
Event: CommandLoader.OnLoadCommandTable []
Loaded module 'batch' in 0.007 seconds.
Loaded module 'batchai' in 0.002 seconds.
Loaded module 'billing' in 0.001 seconds.
Loaded module 'botservice' in 0.002 seconds.
Event: CommandLoader.OnLoadCommandTable []
Loaded module 'cdn' in 0.001 seconds.
Loaded module 'cloud' in 0.001 seconds.
Loaded module 'cognitiveservices' in 0.001 seconds.
Loaded module 'configure' in 0.000 seconds.
Loaded module 'consumption' in 0.001 seconds.
Loaded module 'container' in 0.001 seconds.
Loaded module 'cosmosdb' in 0.002 seconds.
Loaded module 'dla' in 0.002 seconds.
Loaded module 'dls' in 0.003 seconds.
Loaded module 'dms' in 0.002 seconds.
Loaded module 'eventgrid' in 0.001 seconds.
Loaded module 'eventhubs' in 0.002 seconds.
Loaded module 'extension' in 0.001 seconds.
Loaded module 'feedback' in 0.000 seconds.
Loaded module 'find' in 0.000 seconds.
Loaded module 'hdinsight' in 0.001 seconds.
Loaded module 'interactive' in 0.000 seconds.
Loaded module 'iot' in 0.003 seconds.
Loaded module 'iotcentral' in 0.001 seconds.
Loaded module 'keyvault' in 0.004 seconds.
Loaded module 'lab' in 0.002 seconds.
Loaded module 'maps' in 0.001 seconds.
Loaded module 'monitor' in 0.003 seconds.
Loaded module 'network' in 0.022 seconds.
Loaded module 'policyinsights' in 0.001 seconds.
Loaded module 'profile' in 0.001 seconds.
Loaded module 'rdbms' in 0.003 seconds.
Loaded module 'redis' in 0.001 seconds.
Loaded module 'relay' in 0.002 seconds.
Loaded module 'reservations' in 0.001 seconds.
Loaded module 'resource' in 0.004 seconds.
Loaded module 'role' in 0.003 seconds.
Loaded module 'search' in 0.001 seconds.
Loaded module 'servicebus' in 0.002 seconds.
Loaded module 'servicefabric' in 0.001 seconds.
Loaded module 'signalr' in 0.001 seconds.
Loaded module 'sql' in 0.006 seconds.
Event: CommandLoader.OnLoadCommandTable []
Loaded module 'storage' in 0.041 seconds.
Loaded module 'vm' in 0.010 seconds.
Loaded all modules in 0.179 seconds. (note: there's always an overhead with the first module loaded)
Extensions directory: '/home/lawrence/.azure/cliextensions'
Found 1 extensions: ['interactive']
Loaded extension 'interactive' in 0.000 seconds.
Event: CommandInvoker.OnPreCommandTableTruncate []
Event: CommandLoader.OnLoadArguments []
Event: CommandInvoker.OnPostCommandTableCreate [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7f6f3e5ac1e0>, <function register_ids_argument.<locals>.add_ids_arguments at 0x7f6f3e5dab70>]
Event: CommandInvoker.OnCommandTableLoaded []
Event: CommandInvoker.OnPreParseArgs [<function _documentdb_deprecate at 0x7f6f3bc01158>]
Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7f6f3e8ed378>, <function CLIQuery.handle_query_parameter at 0x7f6f3e8a2e18>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7f6f3e5dabf8>, <function handler at 0x7f6f3bb557b8>]
attempting to read file ./pool.json as utf-8-sig
Getting management service client client_type=BatchManagementClient
msrest.universal_http.requests : Configuring retry: max_retries=4, backoff_factor=0.8, max_backoff=90
msrest.universal_http.requests : Configuring retry: max_retries=4, backoff_factor=0.8, max_backoff=90
msrest.async_paging : Paging async iterator protocol is not available for BatchAccountPaged
msrest.service_client : Accept header absent and forced to application/json
attempting to read file /home/lawrence/.azure/accessTokens.json as utf-8-sig
REMOVED TOKEN STUFF
msrest.http_logger : Request URL: 'https://management.azure.com/subscriptions/SUBIDHERE/providers/Microsoft.Batch/batchAccounts?api-version=2017-09-01'
msrest.http_logger : Request method: 'GET'
msrest.http_logger : Request headers:
msrest.http_logger :     'Accept': 'application/json'
msrest.http_logger :     'Content-Type': 'application/json; charset=utf-8'
msrest.http_logger :     'accept-language': 'en-US'
msrest.http_logger :     'User-Agent': 'python/3.6.5 (Linux-4.15.0-43-generic-x86_64-with-debian-buster-sid) msrest/0.6.2 msrest_azure/0.6.0 azure-mgmt-batch/5.0.1 Azure-SDK-For-Python AZURECLI/2.0.54'
msrest.http_logger : Request body:
msrest.http_logger : None
msrest.universal_http : Configuring redirects: allow=True, max=30
msrest.universal_http : Configuring request: timeout=100, verify=True, cert=None
msrest.universal_http : Configuring proxies: ''
msrest.universal_http : Evaluate proxies against ENV settings: True
urllib3.connectionpool : Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool : https://management.azure.com:443 "GET /subscriptions/SUBIDHERE/providers/Microsoft.Batch/batchAccounts?api-version=2017-09-01 HTTP/1.1" 200 None
msrest.http_logger : Response status: 200
msrest.http_logger : Response headers:
msrest.http_logger :     'Cache-Control': 'no-cache'
msrest.http_logger :     'Pragma': 'no-cache'
msrest.http_logger :     'Transfer-Encoding': 'chunked'
msrest.http_logger :     'Content-Type': 'application/json; charset=utf-8'
msrest.http_logger :     'Content-Encoding': 'gzip'
msrest.http_logger :     'Expires': '-1'
msrest.http_logger :     'Vary': 'Accept-Encoding'
msrest.http_logger :     'x-ms-ratelimit-remaining-subscription-reads': '11999'
msrest.http_logger :     'x-ms-request-id': '4736cccf-9f33-4dd1-a1b1-4f366098a895'
msrest.http_logger :     'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
msrest.http_logger :     'X-Content-Type-Options': 'nosniff'
msrest.http_logger :     'Server': 'Microsoft-HTTPAPI/2.0'
msrest.http_logger :     'x-ms-correlation-request-id': '60b335a0-2d10-46c6-adbd-a2e036e67f96'
msrest.http_logger :     'x-ms-routing-request-id': 'UKSOUTH2:20190103T132628Z:60b335a0-2d10-46c6-adbd-a2e036e67f96'
msrest.http_logger :     'Date': 'Thu, 03 Jan 2019 13:26:27 GMT'
msrest.http_logger : Response content:
msrest.http_logger : {"value":[{"id":"/subscriptions/SUBIDHERE/resourceGroups/opencga5/providers/Microsoft.Batch/batchAccounts/batchaccountnamehere","name":"batchaccountnamehere","type":"Microsoft.Batch/batchAccounts","location":"uksouth","properties":{"accountEndpoint":"batchaccountnamehere.uksouth.batch.azure.com","provisioningState":"Succeeded","dedicatedCoreQuota":20,"lowPriorityCoreQuota":100,"poolQuota":100,"activeJobAndJobScheduleQuota":300,"autoStorage":{"storageAccountId":"/subscriptions/SUBIDHERE/resourceGroups/opencga5/providers/Microsoft.Storage/storageAccounts/batchaccountnamehere","lastKeySync":"2019-01-03T11:36:54.8077591Z"},"poolAllocationMode":"BatchService"},"tags":{"ObjectName":"batchaccountnamehere"}}]}
usage: az batch pool create [-h] [--verbose] [--debug]
                            [--output {json,jsonc,table,tsv,yaml}]
                            [--query JMESPATH] [--id ID] [--vm-size VM_SIZE]
                            [--os-family {2,3,4,5}]
                            [--node-agent-sku-id NODE_AGENT_SKU_ID]
                            [--resize-timeout RESIZE_TIMEOUT]
                            [--target-dedicated-nodes TARGET_DEDICATED_NODES]
                            [--target-low-priority-nodes TARGET_LOW_PRIORITY_NODES]
                            [--auto-scale-formula AUTO_SCALE_FORMULA]
                            [--enable-inter-node-communication]
                            [--start-task-command-line START_TASK_COMMAND_LINE]
                            [--start-task-resource-files START_TASK_RESOURCE_FILES [START_TASK_RESOURCE_FILES ...]]
                            [--start-task-wait-for-success]
                            [--certificate-references CERTIFICATE_REFERENCES [CERTIFICATE_REFERENCES ...]]
                            [--application-package-references APPLICATION_PACKAGE_REFERENCES [APPLICATION_PACKAGE_REFERENCES ...]]
                            [--application-licenses APPLICATION_LICENSES [APPLICATION_LICENSES ...]]
                            [--max-tasks-per-node MAX_TASKS_PER_NODE]
                            [--metadata METADATA [METADATA ...]]
                            [--json-file JSON_FILE]
                            [--account-name ACCOUNT_NAME]
                            [--account-key ACCOUNT_KEY]
                            [--account-endpoint ACCOUNT_ENDPOINT]
                            [--image IMAGE] [--subscription _SUBSCRIPTION]
az batch pool create: error: Batch account 'batchaccountnamehere' not found.
Batch Documentation

Most helpful comment

We discussed in our internal SDK/CLI meeting yesterday that we will update error message/unify the http check, so you can probably keep it open until we send out that PR.

All 7 comments

Are you using cloud shell or are you running this on a personal machine? I believe we have a known bug with Cloud Shell requiring you to login to the batch account due to the way cloud shell handles authentication.

I saw this on my dev machine

This seems like a bug then as,
az batch pool create --json-file ./pool.json --account-name batchaccounthere --account-endpoint batchaccounthere.uksouth.batch.azure.com
Should work on a local machine as long as you are logged into the correct subscription.

Will try to replicate this at some point to get a cause.

Looking at our validation logic, it looks like the reason that you got this message was likely that you left off the https:// in your account endpoint when signing. We have custom code in our login cmdlet to check for and add this on, but do not have any such code when a user manually specifies the endpoint.

It may be worth adding a check to generic commands, but the error message is as expected as the account could not be retrieved from the invalid address.

Ah ok that explains the issue then, thanks for taking the time to track it down.

It would be great to fix this up by either editing the error message or adding a check on the Endpoint to ensure that it validates the endpoint URI is of the form https://

The current behavior is confusing as it shows the account name which made me think that was the incorrect parameter and not the endpoint which isn't shown in the error.

az batch pool create: error: Batch account 'batchaccountnamehere' not found.

Should be something like:

az batch pool create: error: Batch account 'batchaccountnamehere' not found at endpoint `endpointhere`.

or my personal preference would be for something like this to happen

az batch pool create: error: Invalid Endpoint provided, please use an endpoint in the format 'https://accountname.location.batch.azure.com'

@bgklein do you plan to take further action on this? If not, I will close the issue.

We discussed in our internal SDK/CLI meeting yesterday that we will update error message/unify the http check, so you can probably keep it open until we send out that PR.

Was this page helpful?
0 / 5 - 0 ratings