Azure/azure-cli

AttributeError: 'NetworkProfile' object has no attribute

Closed this issue ยท 19 comments

Hi,

I am trying to create an ACI in a VNet in West Europe (a supported region for this scenario) and on the first run I see the following error message.

If I run the command a second time it succeeds.

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name
az container create

Errors:

'NetworkProfile' object has no attribute 'result'
Traceback (most recent call last):
Local\Temp\pip-unpacked-wheel-rpp6y7vh\knack\cli.py, ln 215, in invoke
azure\cli\core\commands\__init__.py, ln 659, in execute
azure\cli\core\commands\__init__.py, ln 722, in _run_jobs_serially
azure\cli\core\commands\__init__.py, ln 715, in _run_job
AppData\Local\Temp\pip-unpacked-wheel-igh1xymj\six.py, ln 703, in reraise
azure\cli\core\commands\__init__.py, ln 693, in _run_job
azure\cli\core\commands\__init__.py, ln 330, in __call__
pip-unpacked-wheel-34tyr6f2\azure\cli\core\__init__.py, ln 784, in default_command_handler
azure\cli\command_modules\container\custom.py, ln 190, in create_container
azure\cli\command_modules\container\custom.py, ln 348, in _get_vnet_network_profile
AttributeError: 'NetworkProfile' object has no attribute 'result'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here...
  • az container create --resource-group {} --name {} --image {} --vnet {} --subnet {}

Expected Behavior

Environment Summary

Windows-10-10.0.19041-SP0
Python 3.6.8
Installer: MSI

azure-cli 2.17.1

Extensions:
aks-preview 0.4.71

Additional Context

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dkkapur.

Issue Details

Hi,

I am trying to create an ACI in a VNet in West Europe (a supported region for this scenario) and on the first run I see the following error message.

If I run the command a second time it succeeds.

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name
az container create

Errors:

'NetworkProfile' object has no attribute 'result'
Traceback (most recent call last):
Local\Temp\pip-unpacked-wheel-rpp6y7vh\knack\cli.py, ln 215, in invoke
azure\cli\core\commands\__init__.py, ln 659, in execute
azure\cli\core\commands\__init__.py, ln 722, in _run_jobs_serially
azure\cli\core\commands\__init__.py, ln 715, in _run_job
AppData\Local\Temp\pip-unpacked-wheel-igh1xymj\six.py, ln 703, in reraise
azure\cli\core\commands\__init__.py, ln 693, in _run_job
azure\cli\core\commands\__init__.py, ln 330, in __call__
pip-unpacked-wheel-34tyr6f2\azure\cli\core\__init__.py, ln 784, in default_command_handler
azure\cli\command_modules\container\custom.py, ln 190, in create_container
azure\cli\command_modules\container\custom.py, ln 348, in _get_vnet_network_profile
AttributeError: 'NetworkProfile' object has no attribute 'result'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here...
  • az container create --resource-group {} --name {} --image {} --vnet {} --subnet {}

Expected Behavior

Environment Summary

Windows-10-10.0.19041-SP0
Python 3.6.8
Installer: MSI

azure-cli 2.17.1

Extensions:
aks-preview 0.4.71

Additional Context

Author: plynch66
Assignees: -
Labels:

Container Instances, Service Attention

Milestone: -

container

adiun commented

I got the same error, with the same callstack, but in West US 2. As @plynch66 said, the second time I ran it, it succeeded.

It's like a kind of internal bug. Close the pwsh and try again

That's not really a fix though is it ?

WestEurope, same bug, running the same command second time worked

I experience the same behavior as @czmirek for both West Europe and North Switzerland.

Slightly different output than @plynch66:

ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: 'NetworkProfile' object has no attribute 'result'
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 660, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 723, 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 716, in _run_job
    six.reraise(*sys.exc_info())
  File "/opt/az/lib/python3.6/site-packages/six.py", line 703, in reraise
    raise value
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 694, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 331, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 808, in default_command_handler
    return op(**command_args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/container/custom.py", line 190, in create_container
    network_profile = _get_vnet_network_profile(cmd, location, resource_group_name, vnet, vnet_address_prefix, subnet, subnet_address_prefix)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/container/custom.py", line 348, in _get_vnet_network_profile
    network_profile = ncf.network_profiles.create_or_update(resource_group_name, default_network_profile_name, network_profile).result()
AttributeError: 'NetworkProfile' object has no attribute 'result'

Same behavior on West Europe.
This is the output:

ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: 'NetworkProfile' object has no attribute 'result'
Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 660, in execute
raise ex
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 723, 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 716, in _run_job
six.reraise(*sys.exc_info())
File "/opt/az/lib/python3.6/site-packages/six.py", line 703, in reraise
raise value
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 694, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 331, in call
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/init.py", line 808, in default_command_handler
return op(**command_args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/container/custom.py", line 190, in create_container
network_profile = _get_vnet_network_profile(cmd, location, resource_group_name, vnet, vnet_address_prefix, subnet, subnet_address_prefix)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/container/custom.py", line 348, in _get_vnet_network_profile
network_profile = ncf.network_profiles.create_or_update(resource_group_name, default_network_profile_name, network_profile).result()
AttributeError: 'NetworkProfile' object has no attribute 'result'

We got the same error, any news from Microsoft?

container instance service team should look into this issue.

Same issue in Australia East, failed on first attempt, succeeded on second. Making it difficult to automate.

Same issue when using https://github.com/microsoft/azure-pipelines-ephemeral-agents. First time the pipeline fails and then you have to manually re-run the failed pipeline to get over this issue.

Happens when az container create executed with Powershell via Azure Portal. Second call to az container create ... seems to end up with success. Private IP is allocated properly. Then I can associate it with APP GW Backend Pool. And access my container via APP GP public IP.

PS /home/robert> az container create `
>>   --name ${AZ_CONTAINER_GROUP_NAME} `
>>   --resource-group ${AZ_RESOURCE_GROUP_NAME} `
>>   --image ${AZ_CONTAINER_GROUP_IMAGE} `
>>   --vnet ${AZ_VNET_NAME_CONTAINER_GROUP} `
>>   --subnet ${AZ_SUBNET_NAME_VNET_CONTAINER_GROUP}
The command failed with an unexpected error. Here is the traceback:
'NetworkProfile' object has no attribute 'result'
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 660, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 723, 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 716, in _run_job
    six.reraise(*sys.exc_info())
  File "/opt/az/lib/python3.6/site-packages/six.py", line 703, in reraise
    raise value
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 694, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 331, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 811, in default_command_handler
    return op(**command_args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/container/custom.py", line 190, in create_container
    network_profile = _get_vnet_network_profile(cmd, location, resource_group_name, vnet, vnet_address_prefix, subnet, subnet_address_prefix)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/container/custom.py", line 348, in _get_vnet_network_profile
    network_profile = ncf.network_profiles.create_or_update(resource_group_name, default_network_profile_name, network_profile).result()
AttributeError: 'NetworkProfile' object has no attribute 'result'
To open an issue, please run: 'az feedback'

with full script

Set-StrictMode -Version Latest


$AZ_RESOURCE_GROUP_NAME="myResourceGroup000"
$AZ_LOCATION="eastus"
$AZ_CONTAINER_GROUP_NAME="appcontainer"
$AZ_CONTAINER_GROUP_IMAGE="mcr.microsoft.com/azuredocs/aci-helloworld"
$AZ_VNET_NAME_CONTAINER_GROUP="myVNet"
$AZ_SUBNET_NAME_VNET_CONTAINER_GROUP="myACISubnet"
$AZ_SUBNET_NAME_VNET_APP_GATEWAY="myAGSubnet"
$AZ_BACKEND_POOL_APP_GATEWAY_NAME="myAppGatewayBackendPool"
$AZ_PUBLIC_IP_NAME_APP_GATEWAY="myAGPublicIPAddress"
$AZ_APP_GATEWAY_NAME="myAppGateway"
# Connect-AzAccount
# Select-Azsubscription -SubscriptionName $AZ_SUBSCRIPTION_ID

# Based on 
# https://docs.microsoft.com/en-us/azure/container-instances/container-instances-application-gateway

# Create Resource Group
az group create `
  --name ${AZ_RESOURCE_GROUP_NAME} `
  --location ${AZ_LOCATION}

# Create VNET with default Subnet
az network vnet create `
  --name ${AZ_VNET_NAME_CONTAINER_GROUP} `
  --resource-group ${AZ_RESOURCE_GROUP_NAME} `
  --location ${AZ_LOCATION} `
  --address-prefix 10.0.0.0/16 `
  --subnet-name ${AZ_SUBNET_NAME_VNET_APP_GATEWAY} `
  --subnet-prefix 10.0.1.0/24

# Create Subnet for Container Group in VNET
az network vnet subnet create `
  --name ${AZ_SUBNET_NAME_VNET_CONTAINER_GROUP} `
  --resource-group ${AZ_RESOURCE_GROUP_NAME} `
  --vnet-name ${AZ_VNET_NAME_CONTAINER_GROUP}   `
  --address-prefix 10.0.2.0/24

# Create Public IP for APP GW
az network public-ip create `
  --resource-group ${AZ_RESOURCE_GROUP_NAME} `
  --name ${AZ_PUBLIC_IP_NAME_APP_GATEWAY} `
  --allocation-method Static `
  --sku Standard

# Create APP GW
az network application-gateway create `
  --name ${AZ_APP_GATEWAY_NAME} `
  --location ${AZ_LOCATION} `
  --resource-group ${AZ_RESOURCE_GROUP_NAME} `
  --capacity 2 `
  --sku Standard_v2 `
  --http-settings-protocol http `
  --public-ip-address ${AZ_PUBLIC_IP_NAME_APP_GATEWAY} `
  --vnet-name ${AZ_VNET_NAME_CONTAINER_GROUP} `
  --subnet ${AZ_SUBNET_NAME_VNET_APP_GATEWAY} `


# Create Container Group with one container
az container create `
  --name ${AZ_CONTAINER_GROUP_NAME} `
  --resource-group ${AZ_RESOURCE_GROUP_NAME} `
  --image ${AZ_CONTAINER_GROUP_IMAGE} `
  --vnet ${AZ_VNET_NAME_CONTAINER_GROUP} `
  --subnet ${AZ_SUBNET_NAME_VNET_CONTAINER_GROUP}

# Print private IP of Container Group 
az container show `
  --name ${AZ_CONTAINER_GROUP_NAME} `
  --resource-group ${AZ_RESOURCE_GROUP_NAME} `
  --query ipAddress.ip --output tsv

# Get private IP of Container Group  
ACI_IP=$(az container show `
  --name ${AZ_CONTAINER_GROUP_NAME} `
  --resource-group ${AZ_RESOURCE_GROUP_NAME} `
  --query ipAddress.ip --output tsv)

# Create Backend Pool in APP GW that will route to private IP of Container Group  
az network application-gateway address-pool create `
  --gateway-name ${AZ_APP_GATEWAY_NAME} `
  --name ${AZ_BACKEND_POOL_APP_GATEWAY_NAME} `
  --resource-group ${AZ_RESOURCE_GROUP_NAME}`
  --servers "$ACI_IP" 

# Get public IP of APP GW 
PUB_IP=$(az network public-ip show `
--resource-group ${AZ_RESOURCE_GROUP_NAME} `
--name ${AZ_PUBLIC_IP_NAME_APP_GATEWAY} `
--query [ipAddress] `
--output tsv)

curl $PUB_IP

echo $PUB_IP

echo "Go to azure portal and tweak accordingly the resources. Then download deployment of whole resource group, clean up, and ship it."

tagging appropriate person for followup! @macolso

This should be fixed in version 2.22.0 of azure-cli.

Same, got the error the first time, not the second.
My command was az container create --name *** -g *** --image *** --vnet *** --subnet *** --registry-username *** --registry-password ***

@Peder2911 , what version of azure CLI did you use?

Hey! My bad, I was on 2.20, sorry, should've read the thread before replying.
Keep up the great work!
P

Awesome! Glad it's working.