Error when install Azure-Cli on my self hosted windows agent - azure

I have Azure DevOps pipelines using my Windows Self-hosted agent on my intranet.
I want pipelines to create universal packages and I read that I must install an extension to Azure-Cli on the agent for this.
After several errors where system team helped me setup proxy and all, I run this command in elevated command prompt:
az extension add --name azure-devops
I have this error message:
Unable to get extension index.
Response body does not contain valid json. Error detail: Expecting value: line 1 column 1 (char 0)
What could be the issue ?

First of all, as Doris said, you need meet the most basic conditions for installing the azure-devops extension, that is, the version of az cli should be higher than 2.0.69. But as far as I know, this should not be the cause of issue you encountered.
azure cli along with extensions are all built with python. So you will find that "Error detail: Expecting value: line 1 column 1 (char 0)" is a normal JSONParseDecode error if you google it. It has many causes, like empty response, non-json response content, 500/503 error and etc. Without internet trace, I'm afraid it's hard to find the exact cause of it.
Work around:
========================================
To work around this issue so that you can use az devops command to achieve your goal, you can follow below steps:
1) Install the corresponding whl file into your local machine.
2) Retrieve the downloaded whl file location, then run this command from your command line(Here I would show you the sample script I used):
az extension add --source C:\Users\merlinl\Downloads\azure_devops-0.18.0-py2.py3-none-any.whl
3) Now you will see that the azure-devops installed successfully.

Check your CLI version.
You must have at least v2.0.69, which you can verify with az --version command. Refer to this.

Related

Has az login stopped working in Ubuntu 20.04?

I have used the azure command line some months back without problems. Today I needed to use it again. Nothing has changed in my system, and I am still using the same organization.
I run az login from my terminal (Ubuntu 20.04) and I am shown a browser window. I login to my Azure account. The page replies with:
You have logged into Microsoft Azure! You can close this window, or we
will redirect you to the Azure CLI documents in 10 seconds.
The terminal then displays the authentication reply (a long json response). So far so good.
Now I try to do something with the azure cli, in this case trigger a pipeline:
az pipelines run --output table --organization https://dev.azure.com/MyOrg/ --project MyProj --name MyRepo --branch refs/heads/y/branch --open
But it complains with:
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.
This was not the case some months back. What happened here?
EDIT
This is my az cli:
ยป az --version
azure-cli 2.34.1
core 2.34.1
telemetry 1.0.6
Extensions:
azure-devops 0.18.0
Dependencies:
msal 1.16.0
azure-mgmt-resource 20.0.0
Python location '/opt/az/bin/python3'
Extensions directory '/home/theuser/.azure/cliextensions'
Python (Linux) 3.8.12 (default, Mar 2 2022, 07:26:21)
[GCC 9.3.0]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Please let us know how we are doing: https://aka.ms/azureclihats
and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy
I have tried the same ,to upgrade my CLI version and it failed several times and now only got succeed the error might be you are getting due to some recent changes still going on with 2.34.1 version.
Would suggest you use the old version of CLI and then check or, for Workaround you can use az devops login using PAT token .
You can refer the same document to login with PAT which one you are getting in an error .
For more information please refer this GitHub issue as suggested by #wiruzman

How to install Azure CLI Billing Account

I am trying to run
az billing account list
However, when I run this I get:
az billing: 'account' is not in the 'az billing' command group. See 'az billing --help'. If the command is from an extension, please make sure the corresponding extension is installed. To learn more about extensions, please visit https://learn.microsoft.com/en-us/cli/azure/azure-cli-extensions-overview
I have installed the account extension but it still has not worked.
If I run it in the Cloud Shell I get:
Command group 'billing account' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
[]
so I do get a response here.
I cannot find anything to install this extension or preview extentions.
Repo doesn't have it https://github.com/Azure/azure-cli
Python Repo doesn't have it https://pypi.org/user/microsoft/
No information on the Documentation https://learn.microsoft.com/en-us/rest/api/billing/2019-10-01-preview/billingaccounts
listing the extensions doesn't show anyting https://learn.microsoft.com/en-us/cli/azure/azure-cli-extensions-overview
The upgraded billing commands are shipped with Azure CLI 2.15.0 and the Cloud Shell you are using with Azure might be an older version, Try to update and see

Unable to remove faulted Node using Remove-ServiceFabricNodeState any more

I used to use Remove-ServiceFabricNodeState to remove faulted Service Fabric nodes. with this cmdlet i was able to remove a specific node by its name.
However I'm unable to use this cmdlet any more. It is not allowing me to install the module using Install-Module ServiceFabric anymore saying the module cannot be found in the gallery.
Also I'm unable to find a similar cmdlet in iether Az.ServiceFabric or az cli. all that is available is a Remove-AzServiceFabricNode which cannot specify which node I want to remove. It just accepts an integer for how many nodes I want to remove.
I would like to know how can I remove a Node by its name?
To use Remove-ServiceFabricNodeState, just need to install the Azure Service Fabric SDK, it also includes the runtime and tools, after installing it, reopen a PowerShell session, you will be able to use the command.
Besides, you can also use the Azure Service Fabric CLI command sfctl node remove-state as mentioned in another reply, all depend on your requirement.
You can use Azure Service Fabric CLI with
sfctl node remove-state --node-name Node01 --timeout 60
This will remove the state of Node1 with a timeout of 60 seconds. Documnetation
For more information on how to install sfctl see how to install sfctl
Simple version:
Install Python (Version 3.X)
Install Pip
Execute the following command pip install -I sfctl==9.0.0. See table to see which version you need.

Getting error trying to make Terraform work with IBM Cloud

I am using the following instructions:
https://console.bluemix.net/docs/terraform/setup_cli.html#setup_cli
When I run terraform init
I get the following error:
Provider "ibm" not available for installation.
A provider named "ibm" could not be found in the official repository.
This may result from mistyping the provider name, or the given provider may
be a third-party provider that cannot be installed automatically.
In the latter case, the plugin must be installed manually by locating and
downloading a suitable distribution package and placing the plugin's executable
file in the following directory:
terraform.d/plugins/windows_amd64
Terraform detects necessary plugins by inspecting the configuration and state.
To view the provider versions requested by each module, run
"terraform providers".
I am on windows 10 pc, I tried placing following executable under:
$HOME/terraform.d/plugins/windows_amd64/terraform-provider-ibm_v0.14.1.exe
Can anyone point why this is not working?
I think there is a bug in instructions of IBM Cloud. But when I put the executable file under the following path it works:
$HOME\terraform.d\plugins\terraform-provider-ibm_v0.14.1.exe
Hope this answer will help save someone some time.
There are clear steps on how to configure the IBM Cloud Provider for Terraform in this solution tutorial on both Windows and non-windows operating systems.
On Windows, the file needs to be placed in terraform.d/plugins beneath your user's "Application Data" directory.
Run the below commands on a command prompt Provider Configuration
MD %USERPROFILE%\AppData\terraform.d\plugins
MOVE PATH_TO_UNZIPPED_PROVIDER_FILE\terraform-provider-ibm.exe %USERPROFILE%\AppData\terraform.d\plugins
Launch Windows Powershell (Start + R > Powershell) and run the below command to create terraform.rc file
echo > $env:APPDATA\terraform.rc
At the first prompt, enter the below content
# ~/.terraformrc
providers {
ibm = "PATH_TO_YOUR_APPDATA_PLUGINS/terraform-provider-ibm.exe"
}
The file terraform.rc should be saved with Encoding ANSI and you have to be sure of not having weird characters.

Cannot install Azure Dev Spaces using cloud shell in AKS

When i run the below command in cloud shell.
az aks use-dev-spaces -g aksrgrp -n akscluster
I get the below error. Any help will be highly appreciated
You may be prompted for your administrator password to authorize the installation process.
/tmp/tmpy1vng2we/azds-linux-setup.sh: line 84: sudo: command not found
/tmp/tmpy1vng2we/azds-linux-setup.sh: line 112: sudo: command not found
[INFO] Failed to install dotnet core dependencies.
[INFO] You can manually install all required dependencies based on the following documentation:
[FATAL] https://www.microsoft.com/net/download/dotnet-core/2.1
Azure Dev Spaces CLI not installed properly. Visit 'https://aka.ms/get-azds' for Azure Dev Spaces.
The error shows why the issue happens. It cannot find the command azds. Because the cloud shell does not install the command tool. You can find all the command tools installed in the cloud shell here.
I suggest you can install the tool which you need in the Azure VM of the azure Kubernetes, if you do not find the tool what you want.
It's a better way for you. By the way, the Cloud Shell just enables access to a browser-based command-line experience built with Azure management tasks in mind. So install the Azure CLI in the VM is a better experience.
To add to Charles's answer: the Azure Dev Spaces CLI currently does not support running in the Cloud Shell. Its functionality is designed more for running on your local dev machine where you application's source code is.

Resources