AzureDevOpsQuickNotes - henk52/knowledgesharing GitHub Wiki

Azure devops quick notes

Introduction

References

  • Evolve your DevOps practices:

Vocabulary

  • AD - Active directory.
  • managed identities - providing an identity for the Azure resource in Azure AD and using it to obtain Azure Active Directory (Azure AD) tokens.
  • Managed identity types -
    • System-assigned: an identity is created in Azure AD that is tied to the lifecycle of that service instance. So when the resource is deleted, Azure automatically deletes the identity for you.
    • User-assigned: the identity is managed separately from the resources that use it.
  • Service Point -

Installation

Installing az

Installing az on Ubuntu

See:

Installing az on Windows 10

See: Choose the second method, so that it becomes part of the repos and are auto updated with apt update/upgrade

  • Download installer from:
  • run the azure-cli-*.msi installer
  • Accept license terms and click 'Install'
  • click 'Yes' to allow app to make changes to system.
  • click 'Finished' when done
    • The installation take 5-8 minutes?

Artifacts

  1. az login
  2. az artifacts universal publish --organization "https://dev.azure.com/ORG/" --feed "FEED_NAME" --name "ARTIFACT_NAME" --path . --version "1.2.3" --description "A DESCRIPTION"

Troubleshooting

Troubleshooting keyvault access with python

ModuleNotFoundError: No module named 'azure'

This was due to running python3 on an Ubuntu 18.04 where the default is python2 and the pip installed python2 modules

python3 test_kv_secret.py 
Traceback (most recent call last):
  File "test_kv_secret.py", line 4, in <module>
    from azure.identity import DefaultAzureCredential
ModuleNotFoundError: No module named 'azure'

ModuleNotFoundError: No module named 'azure.identity'

This was due to running python3 on an Ubuntu 18.04 where the default is python2 and the pip installed python2 modules

python3 test_kv_secret.py 
Traceback (most recent call last):
  File "test_kv_secret.py", line 4, in <module>
    from azure.identity import DefaultAzureCredential
ModuleNotFoundError: No module named 'azure.identity'

ModuleNotFoundError: No module named 'adal'

Base Python3 Azure package was not installed.

troubleshoot templates

Message: Unable to edit or replace deployment 'vm-template': previous deployment from is still active

See:

If you browse the resource group in the portal, at the upper part of the main list , it will state '1 deploying,...' Click that link and cancel the vm-template ongoing deployment.

troublseshooting pipeline execution on ubuntu

sudo: no tty present and no askpass program specified

Fix:

  • sudo visudo
    • `%sudo ALL=(ALL:ALL) NOPASSWD: ALL``

Before you can run Azure DevOps commands, you need to run the login command(az login if using AAD/MSA identity else az devops login if using PAT token) to setup credentials. Please see https://aka.ms/azure-devops-cli-auth for more information

Missing: export AZURE_DEVOPS_EXT_PAT=$(System.AccessToken) in run command.

and az devops login

TF400813: Resource not available for anonymous access. Client authentication required

It seems to be due to AZURE_DEVOPS_EXT_PAT being empty.

Failed to update Universal Packages tooling.
 TF400813: Resource not available for anonymous access. Client authentication required.

ImportError: No module named profiles

Traceback (most recent call last):
  File "/home/ngcp-svc/japtalog2kibana.py", line 16, in <module>
    from azure.keyvault.secrets import SecretClient
  File "/usr/local/lib/python2.7/dist-packages/azure/keyvault/secrets/__init__.py", line 5, in <module>
    from ._models import DeletedSecret, KeyVaultSecret, SecretProperties
  File "/usr/local/lib/python2.7/dist-packages/azure/keyvault/secrets/_models.py", line 5, in <module>
    from ._shared import parse_vault_id
  File "/usr/local/lib/python2.7/dist-packages/azure/keyvault/secrets/_shared/__init__.py", line 14, in <module>
    from .client_base import KeyVaultClientBase
  File "/usr/local/lib/python2.7/dist-packages/azure/keyvault/secrets/_shared/client_base.py", line 12, in <module>
    from .._generated import KeyVaultClient as _KeyVaultClient
  File "/usr/local/lib/python2.7/dist-packages/azure/keyvault/secrets/_generated/__init__.py", line 9, in <module>
    from ._key_vault_client import KeyVaultClient
  File "/usr/local/lib/python2.7/dist-packages/azure/keyvault/secrets/_generated/_key_vault_client.py", line 15, in <module>
    from azure.profiles import KnownProfiles, ProfileDefinition
ImportError: No module named profiles
⚠️ **GitHub.com Fallback** ⚠️