Azure / Azure/azure-cli

Az CLI doesn't work through CMake

Open
#15,910 3 comments 0 reactions 0 assignees View on GitHub
act-platform-engineering-squad DevOps Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Describe the bug**
When trying to execute a AZ cli command through cmake execute_process, it fails

**To Reproduce**
Azure Cli Version:
azure-cli 2.14.2
core 2.14.2
telemetry 1.0.6

Azure-Devops extension version:
azure-devops 0.18.0

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'

Steps to reproduce the behavior:

1. On Window, install the latest Az CLI, install CMake 3.17.0
2. Create a folder with a file called CMakeLists.txt with content:

```
cmake_minimum_required(VERSION 3.17)
project("Aztest")
execute_process(COMMAND ping /n 1 127.0.0.1 RESULT_VARIABLE p)
MESSAGE(STATUS "Ping ended with code " ${p})
execute_process(COMMAND az --version RESULT_VARIABLE code)
MESSAGE(STATUS "Az CLI version ended with code " ${code})
```

3. Launch CMake, choose the folder containing the CMakeLists.txt as a source
4. Click on configure
5. Output is:

```
Pinging 127.0.0.1
with 32 bytes of data:

Reply from 127.0.0.1:
bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

Ping ended with code 0
Az CLI Help version with code The system cannot find the file specified
Configuring done
```

**Expected behavior**
Az CLI should be executed correctly.

**Environment summary**
Windows 10, CMake 3.17.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.