missing 1 required positional argument: 'target_ip_address'
Hi,
On wsl/debian : azure-cli 2.44.1 * bastion 0.2.0 azure-devops 0.26.0
or windows 10 : azure-cli 2.45.0 bastion 0.2.0 ssh 1.1.3
While executing az network bastion tunnel, I've obtain the following error :
.azure/cliextensions/bastion/azext_bastion/custom.py", line 349, in create_bastion_tunnel _validate_and_generate_resourceid(cmd, bastion, target_resource_id, target_ip_address) TypeError: _validate_and_generate_resourceid() missing 1 required positional argument: 'target_ip_address'
Before installing the bastion extension (which is required now after an upgrade of azure-cli), I manage to open a tunnel to my azure bastion.
Thx
Same issue here. I guess it started with version of az cli 2.40+. I tried only newest 2.45.0-1~bullseye and 2.44.1-1~bullseye. Didn't tried more, had to work, didn't have time to play with it.
Another thing is that with those new az cli versions, bastion tunnel doesn't work with IP. This is the output from az network bastion tunnel -h
Examples
Open a tunnel through Azure Bastion to a target virtual machine using resourceId.
az network bastion tunnel --name MyBastionHost --resource-group MyResourceGroup --target-
resource-id vmResourceId --resource-port 22 --port 50022
Open a tunnel through Azure Bastion to a target virtual machine using its IP address.
az network bastion tunnel --name MyBastionHost --resource-group MyResourceGroup --target-ip-
address 10.0.0.1 --resource-port 22 --port 50022
With first example, it always tell that --target-ip-address is missing. If I add this argument with IP of VM where I want to tunnel, it still tells that --target-ip-address is missing.
If I try second example, without resource-id only with --target-ip, it tells that resource-id is missing and ignoring --target-ip-address.
route to CXP team
I have the same problem with az network bastion ssh:
➜ ~ az network bastion ssh -n bas-sharedBastion-prod-hub-001 --subscription hub-net \
-g rg-hub-net --auth-type AAD --target-resource-id \
/subscriptions/****/resourceGroups/***/providers/Microsoft.Compute/virtualMachines/vm-utility-001 \
--target-ip-address 10.1.1.4
Command group 'az network' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
The command failed with an unexpected error. Here is the traceback:
_validate_and_generate_resourceid() missing 1 required positional argument: 'target_ip_address'
{
"azure-cli": "2.45.0",
"azure-cli-core": "2.45.0",
"azure-cli-telemetry": "1.0.8",
"extensions": {
"bastion": "0.2.0",
"containerapp": "0.3.21",
"ssh": "1.1.3"
}
}
Same issue here (mac os 13.2, azure-cli 2.45.0) with az network bastion tunnel
Same issue here, right after azure-cli 2.45.0 update and installing the imposed bastion extension
Reproduce:
az network bastion ssh --subscription {} --name {} --resource-group {} --target-resource-id {} --auth-type ssh-key --username {} --ssh-key {}
Error:
The command failed with an unexpected error. Here is the traceback:
_validate_and_generate_resourceid() missing 1 required positional argument: 'target_ip_address'
Traceback (most recent call last):
File "/opt/az/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
raise ex
File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/home/ch071771/.azure/cliextensions/bastion/azext_bastion/custom.py", line 153, in ssh_bastion_host
_validate_and_generate_resourceid(cmd, bastion, target_resource_id, target_ip_address)
TypeError: _validate_and_generate_resourceid() missing 1 required positional argument: 'target_ip_address'
Environment Summary
Linux-5.15.0-56-generic-x86_64-with-glibc2.35, Ubuntu 22.04.1 LTS
Python 3.10.8
Installer: DEB
azure-cli 2.45.0
Extensions:
bastion 0.2.0
ssh 1.1.3
Dependencies:
msal 1.20.0
azure-mgmt-resource 21.1.0b1
Same issue here
I also ran into this. I hacked around it by editing the bastion extension file ~/.azure/cliextensions/bastion/azext_bastion/custom.py on line 287 where the _validate_and_generate_resourceid() function is defined, and setting a default target ip value of a random address in the AzureBastionSubnet subnet range. This allowed the bastion connection to work.
I also ran into this. I hacked around it by editing the bastion extension file ~/.azure/cliextensions/bastion/azext_bastion/custom.py on line 287 where the _validate_and_generate_resourceid() function is defined, and setting a default target ip value of a random address in the AzureBastionSubnet subnet range. This allowed the bastion connection to work.
This worked for me thanks @maxwmsft
I also ran into this. I hacked around it by editing the bastion extension file ~/.azure/cliextensions/bastion/azext_bastion/custom.py on line 287 where the _validate_and_generate_resourceid() function is defined, and setting a default target ip value of a random address in the AzureBastionSubnet subnet range. This allowed the bastion connection to work.
Worked for me. Thanks @maxwmsft
I also ran into this. I hacked around it by editing the bastion extension file ~/.azure/cliextensions/bastion/azext_bastion/custom.py on line 287 where the _validate_and_generate_resourceid() function is defined, and setting a default target ip value of a random address in the AzureBastionSubnet subnet range. This allowed the bastion connection to work.
In my case I get this output:
Bastion does not have IP Connect feature enabled, please enable and try again
I also ran into this. I hacked around it by editing the bastion extension file ~/.azure/cliextensions/bastion/azext_bastion/custom.py on line 287 where the _validate_and_generate_resourceid() function is defined, and setting a default target ip value of a random address in the AzureBastionSubnet subnet range. This allowed the bastion connection to work.
This worked for me too, but now I get:
Traceback (most recent call last): File "/usr/local/Cellar/[email protected]/3.10.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/usr/local/Cellar/[email protected]/3.10.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "/Users/tuncay/.azure/cliextensions/bastion/azext_bastion/custom.py", line 325, in _start_tunnel tunnel_server.start_server() File "/Users/tuncay/.azure/cliextensions/bastion/azext_bastion/tunnel.py", line 194, in start_server self._listen() File "/Users/tuncay/.azure/cliextensions/bastion/azext_bastion/tunnel.py", line 123, in _listen auth_token = self._get_auth_token() File "/Users/tuncay/.azure/cliextensions/bastion/azext_bastion/tunnel.py", line 110, in _get_auth_token raise exp msrestazure.azure_exceptions.CloudError: java.lang.NullPointerException ~ ❯
The problem here is that the call to _validate_and_generate_resourceid() in ssh_bastion_host() and create_bastion_tunnel() is missing the resource_group_name parameter.
The call looks like this:
_validate_and_generate_resourceid(cmd, bastion, target_resource_id, target_ip_address)
but should be like this:
_validate_and_generate_resourceid(cmd, bastion, resource_group_name, target_resource_id, target_ip_address)
With this change I'm able to log in to my VMs again through Bastion SSH.
having the same issue with ssh.
Same issue with the same versions. The fix I had to apply was slightly different as needed to add the resource_group_name to ~/.azure/cliextensions/bastion/azext_bastion/custom.py on line 153.
Same issue with the same versions. The fix I had to apply was slightly different as needed to add the
resource_group_nameto~/.azure/cliextensions/bastion/azext_bastion/custom.pyon line 153.
Fixed it for me... seems like someone forget an argument
resource_group_name
Do you have a gist with the workaround implemented? 😢
I had the same problem after updating Azure CLI. The problem is, that the extension bastion will not be updatet. So after upgrading the extension it's worked for me.
az extension add --upgrade --name bastion
I had the same problem after updating Azure CLI. The problem is, that the extension bastion will not be updatet. So after upgrading the extension it's worked for me.
az extension add --upgrade --name bastion
I removed the extension a few days ago and have just re-installed it. Its now working for me too.
Hi @lgranie. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.
Extension bastion version 0.2.0 is broken (at least for azure-cli version 2.45.0). 0.2.1 works.