title: Azure Managed Service Identity: Failed to acquire tokens after 12 times
body: <p>I have a VM with a system-assigned managed service identitiy. I gave it permission to pull images from the Azure container registry. <a href="https://medium.com/@maninder.bindra/pull-container-images-in-azure-container-registry-acr-from-azure-vm-with-managed-service-identity-d490dab6eb5a" rel="nofollow noreferrer">I followed this tutorial</a>.</p>
  <p>I worked fine yesterday. But when wanting to pull a new image, it said to re-authenticate. This is where it fails. When I either execute one of the following I'm getting errors, stating that the token acquisition failed.</p>
  <p>Am I doing something wrong?</p>
  <blockquote>
  <p>az login --identity</p>
  <p>az acr login --name MYREGISTRY</p>
  </blockquote>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>MSI: Failed to acquire tokens after 12 times
  Traceback (most recent call last):
    File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 206, in invoke
      cmd_result = self.invocation.execute(args)
    File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in execute
      raise ex
    File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 386, in _run_jobs_serially
      results.append(self._run_job(expanded_arg, cmd_copy))
    File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 379, in _run_job
      six.reraise(*sys.exc_info())
    File "/opt/az/lib/python3.6/site-packages/six.py", line 693, in reraise
      raise value
    File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 356, in _run_job
      result = cmd_copy(params)
    File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 171, in __call__
      return self.handler(*args, **kwargs)
    File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 441, in default_command_handler
      return op(**command_args)
    File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/profile/custom.py", line 111, in login
      return profile.find_subscriptions_in_vm_with_msi(username)
    File "/opt/az/lib/python3.6/site-packages/azure/cli/core/_profile.py", line 297, in find_subscriptions_in_vm_with_msi
      msi_creds = MSIAuthentication(resource=resource)
    File "/opt/az/lib/python3.6/site-packages/msrestazure/azure_active_directory.py", line 576, in __init__
      self.set_token()
    File "/opt/az/lib/python3.6/site-packages/msrestazure/azure_active_directory.py", line 584, in set_token
      token_entry = self._vm_msi.get_token(self.resource)
    File "/opt/az/lib/python3.6/site-packages/msrestazure/azure_active_directory.py", line 632, in get_token
      token_entry = self._retrieve_token_from_imds_with_retry(resource)
    File "/opt/az/lib/python3.6/site-packages/msrestazure/azure_active_directory.py", line 674, in _retrieve_token_from_imds_with_retry
      raise TimeoutError('MSI: Failed to acquire tokens after {} times'.format(max_retry))
  TimeoutError: MSI: Failed to acquire tokens after 12 times</code></pre>
  </div>
  </div>
  </p>