internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: Azure/azure-cli-extensions

Issue:
webapp remote-connection create fails if specifying --port on version 0.2.7
### Extension name (the extension in question)
webapp

### Description of issue (in as much detail as possible)
The following command will fail when specifying --port after updating to version 0.2.7. Works fine in 0.2.6.
```
webapp remote-connection create --resource-group rg --name name --port xxx 
```
with the following message:
```
connect_ex() takes exactly one argument (2 given)
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\knack\cli.py", line 197, in invoke
    cmd_result = self.invocation.execute(args)
  File "C:\Users\troyd\AppData\Local\Temp\pip-install-_jje8pgf\azure-cli-core\azure\cli\core\commands\__init__.py", line 369, in execute
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\six.py", line 693, in reraise
    raise value
  File "C:\Users\troyd\AppData\Local\Temp\pip-install-_jje8pgf\azure-cli-core\azure\cli\core\commands\__init__.py", line 343, in execute
  File "C:\Users\troyd\AppData\Local\Temp\pip-install-_jje8pgf\azure-cli-core\azure\cli\core\commands\__init__.py", line 182, in __call__
  File "C:\Users\troyd\AppData\Local\Temp\pip-install-_jje8pgf\azure-cli-core\azure\cli\core\__init__.py", line 436, in default_command_handler
  File "C:\Users\xxx\.azure\cliextensions\webapp\azext_webapp\custom.py", line 254, in create_tunnel
    tunnel_server = TunnelServer('', port, host_name, user_name, user_password)
  File "C:\Users\xxx\.azure\cliextensions\webapp\azext_webapp\tunnel.py", line 42, in __init__
    if self.local_port != 0 and not self.is_port_open():
  File "C:\Users\xxx\.azure\cliextensions\webapp\azext_webapp\tunnel.py", line 69, in is_port_open
    if sock.connect_ex('', self.local_port) == 0:
TypeError: connect_ex() takes exactly one argument (2 given)
```
-----




Discussion:
I suspect this change broke it, I'll test it out
https://github.com/Azure/azure-cli-extensions/commit/8241b5dc24efb4243a1a470e4d504310445463e3#diff-88168b5d56c3f34bf694d46475a1a0b2L68

Resolving patch:
diff --git a/src/webapp/azext_webapp/tunnel.py b/src/webapp/azext_webapp/tunnel.py
--- a/src/webapp/azext_webapp/tunnel.py
+++ b/src/webapp/azext_webapp/tunnel.py
@@ -66,7 +66,7 @@ def create_basic_auth(self):
     def is_port_open(self):
         is_port_open = False
         with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
-            if sock.connect_ex('', self.local_port) == 0:
+            if sock.connect_ex(('', self.local_port)) == 0:
                 logger.info('Port %s is NOT open', self.local_port)
             else:
                 logger.warning('Port %s is open', self.local_port)
diff --git a/src/webapp/setup.py b/src/webapp/setup.py
--- a/src/webapp/setup.py
+++ b/src/webapp/setup.py
@@ -8,7 +8,7 @@
 from codecs import open
 from setuptools import setup, find_packages
 
-VERSION = "0.2.9"
+VERSION = "0.2.10"
 
 CLASSIFIERS = [
     'Development Status :: 4 - Beta',


Test patch:
Repository: Azure/azure-cli-extensions

Issue:
add timeout support in image copy command
- If the issue is to do with Azure CLI 2.0 in-particular, create an issue here at [Azure/azure-cli](https://github.com/Azure/azure-cli/issues)

### Extension name (the extension in question)
image-copy-extension

### Description of issue (in as much detail as possible)
src/image-copy/azext_imagecopy/create_target.py

at line 50:
https://github.com/Azure/azure-cli-extensions/blob/master/src/image-copy/azext_imagecopy/create_target.py#L50

we are using hardcoded SAS expiration time 1 hour
expiry = datetime.datetime.utcnow() + datetime.timedelta(hours=1)

This could cause problem as some times the copy take longer than 1 hour. Please consider to add a parameter to the image copy command to add a timeout parameter and use the specified timeout(maybe +5min) to generate the SAS token.
-----




Discussion:

Resolving patch:
diff --git a/src/image-copy/azext_imagecopy/create_target.py b/src/image-copy/azext_imagecopy/create_target.py
--- a/src/image-copy/azext_imagecopy/create_target.py
+++ b/src/image-copy/azext_imagecopy/create_target.py
@@ -168,6 +168,9 @@ def wait_for_blob_copy_operation(blob_name, target_container_name, target_storag
 
     if copy_status != 'success':
         logger.error("The copy operation didn't succeed. Last status: %s", copy_status)
+        logger.error("Command run: %s", cli_cmd)
+        logger.error("Command output: %s", json_output)
+
         raise CLIError('Blob copy failed')
 
 
diff --git a/src/image-copy/setup.py b/src/image-copy/setup.py
--- a/src/image-copy/setup.py
+++ b/src/image-copy/setup.py
@@ -8,7 +8,7 @@
 from codecs import open
 from setuptools import setup, find_packages
 
-VERSION = "0.0.8"
+VERSION = "0.0.9"
 
 CLASSIFIERS = [
     'Development Status :: 4 - Beta',


Test patch:
Repository: Azure/azure-cli-extensions

Issue:
min_pro is used in the example of help in express-route-cross-connection
- If the issue is to do with Azure CLI 2.0 in-particular, create an issue here at [Azure/azure-cli](https://github.com/Azure/azure-cli/issues)

### Extension name (the extension in question)
express-route-cross-connection

### Description of issue (in as much detail as possible)
https://github.com/Azure/azure-cli-extensions/blob/bbefbe73a620c6407b522484d6b2ba848cb4f9f5/src/express-route-cross-connection/azext_expressroutecrossconnection/_help.py#L131

We shouldn't use min_profile in the help example. It needs to be updated to supportedprofile instead.
-----




Discussion:
In this case, the value can simply be removed. It serves no purpose.

Resolving patch:
diff --git a/src/express-route-cross-connection/azext_expressroutecrossconnection/_help.py b/src/express-route-cross-connection/azext_expressroutecrossconnection/_help.py
--- a/src/express-route-cross-connection/azext_expressroutecrossconnection/_help.py
+++ b/src/express-route-cross-connection/azext_expressroutecrossconnection/_help.py
@@ -128,5 +128,4 @@
                 --circuit-name MyCircuit --peering-type MicrosoftPeering --ip-version ipv6 \\
                 --primary-peer-subnet 2002:db00::/126 --secondary-peer-subnet 2003:db00::/126 \\
                 --advertised-public-prefixes 2002:db00::/126
-          min_profile: latest
 """
diff --git a/src/express-route-cross-connection/setup.py b/src/express-route-cross-connection/setup.py
--- a/src/express-route-cross-connection/setup.py
+++ b/src/express-route-cross-connection/setup.py
@@ -8,7 +8,7 @@
 from codecs import open
 from setuptools import setup, find_packages
 
-VERSION = "0.1.0"
+VERSION = "0.1.1"
 
 CLASSIFIERS = [
     'Development Status :: 4 - Beta',


Test patch:
Repository: Azure/azure-cli-extensions

Issue:
`front-door backend-pool backend remove` negative indexes allowed/mishandled
### Extension name (the extension in question)

front-door

### Description of issue (in as much detail as possible)

Negative integers passed to the `--index` parameter of the `front-door backend-pool backend remove` command are permitted and remove the element `length - index - 1`

This could be quite bad since I guess a common use case would be to use `indexOf` to get an index and that returns a `-1` if not found. Which could result in an item being incorrectly removed if the result isn't tested before use.

E.g. given the following backends

```
[0]: backend1
[1]: backend2
[2]: backend3
[3]: backend4
```
passing in `-1` will result in `backend3` at position `[2]` being removed.

```
az network front-door backend-pool backend remove -g <RG> -f <FD> --pool-name <POOL> --index -1
```

-----

This seems to be an issue with the use of the `pop` function which allows removing elements from the rear of the array when negative values are passed in. Along with the added complication that the `backend remove` command expects indexes starting from 1.

https://github.com/Azure/azure-cli-extensions/blob/862c3659a15a34ff4e0a5570c7d2aaf7013ef39f/src/front-door/azext_front_door/custom.py#L428




Discussion:
add to S165.
add to S168

Resolving patch:
diff --git a/src/front-door/azext_front_door/custom.py b/src/front-door/azext_front_door/custom.py
--- a/src/front-door/azext_front_door/custom.py
+++ b/src/front-door/azext_front_door/custom.py
@@ -417,17 +417,21 @@ def list_fd_backends(cmd, resource_group_name, front_door_name, backend_pool_nam
 
 
 def remove_fd_backend(cmd, resource_group_name, front_door_name, backend_pool_name, index):
+    from knack.util import CLIError
     client = cf_frontdoor(cmd.cli_ctx, None)
     frontdoor = client.get(resource_group_name, front_door_name)
     backend_pool = next((x for x in frontdoor.backend_pools if x.name == backend_pool_name), None)
     if not backend_pool:
-        from knack.util import CLIError
         raise CLIError("Backend pool '{}' could not be found on frontdoor '{}'".format(
             backend_pool_name, front_door_name))
     try:
-        backend_pool.backends.pop(index - 1)
+        if index > 0:
+            backend_pool.backends.pop(index - 1)
+        elif index < 0:
+            backend_pool.backends.pop(index)
+        else:
+            raise CLIError('invalid index. Index can range from 1 to {}'.format(len(backend_pool.backends)))
     except IndexError:
-        from knack.util import CLIError
         raise CLIError('invalid index. Index can range from 1 to {}'.format(len(backend_pool.backends)))
     client.create_or_update(resource_group_name, front_door_name, frontdoor).result()
 
diff --git a/src/front-door/setup.py b/src/front-door/setup.py
--- a/src/front-door/setup.py
+++ b/src/front-door/setup.py
@@ -8,7 +8,7 @@
 from codecs import open
 from setuptools import setup, find_packages
 
-VERSION = "1.0.3"
+VERSION = "1.0.4"
 
 CLASSIFIERS = [
     'Development Status :: 4 - Beta',


Test patch:
Repository: Azure/azure-cli-extensions

Issue:
Typo in Documentation
### Description of issue (in as much detail as possible)

The delete command's description says Create instead of delete. 

az monitor app-insights component delete | Create a new Application Insights resource.



-----




Discussion:
Hi @MyronFanQiu , could you please take a took at this ?
add to S166.

Resolving patch:
diff --git a/src/application-insights/azext_applicationinsights/_help.py b/src/application-insights/azext_applicationinsights/_help.py
--- a/src/application-insights/azext_applicationinsights/_help.py
+++ b/src/application-insights/azext_applicationinsights/_help.py
@@ -81,9 +81,9 @@
 
 helps['monitor app-insights component delete'] = """
     type: command
-    short-summary: Create a new Application Insights resource.
+    short-summary: Delete a new Application Insights resource.
     examples:
-      - name: Create a component with kind web and location.
+      - name: Delete a component with kind web and location.
         text: |
           az monitor app-insights component delete --app demoApp -g demoRg
 """
diff --git a/src/application-insights/setup.py b/src/application-insights/setup.py
--- a/src/application-insights/setup.py
+++ b/src/application-insights/setup.py
@@ -8,7 +8,7 @@
 from codecs import open
 from setuptools import setup, find_packages
 
-VERSION = "0.1.5"
+VERSION = "0.1.6"
 
 CLASSIFIERS = [
     'Development Status :: 4 - Beta',


Test patch:
Repository: Azure/azure-cli-extensions

Issue:
az network front-door routing-rule create --backend-pool is mandatory
Parameter --backend-pool is documented as optional, but it is mandatory: `BadRequest - Property 'FrontdoorEntity.RoutingRules[1].Properties.RouteConfiguration.BackendPool' is required but it was not set` is the error, if argument was not supplied.

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: bc41d7b5-ab21-fe9b-2f2e-93ac02e5af86
* Version Independent ID: 67398425-8b96-f515-72af-22255ea1ae49
* Content: [az network front-door routing-rule](https://docs.microsoft.com/en-us/cli/azure/ext/front-door/network/front-door/routing-rule?view=azure-cli-latest#ext-front-door-az-network-front-door-routing-rule-create)
* Content Source: [latest/docs-ref-autogen/ext/front-door/network/front-door/routing-rule.yml](https://github.com/MicrosoftDocs/azure-docs-cli/blob/live/latest/docs-ref-autogen/ext/front-door/network/front-door/routing-rule.yml)
* GitHub Login: @rloutlaw
* Microsoft Alias: **routlaw**


Discussion:
HI @MyronFanQiu  could you pls have a look? thanks.
add to S167.
@wasker Thanks. We will fix it later.
@wasker I just checked the code. `--backend-pool` is required when you try to create a Forward routing rule. But it's not required for a Redirect rule. So it's by design to mark it as optional. I updated the help message.

Resolving patch:
diff --git a/src/front-door/azext_front_door/_params.py b/src/front-door/azext_front_door/_params.py
--- a/src/front-door/azext_front_door/_params.py
+++ b/src/front-door/azext_front_door/_params.py
@@ -132,7 +132,7 @@ def load_arguments(self, _):
         c.argument('rules_engine', help='Name or ID of a Rules Engine configuration.', validator=validate_rules_engine)
         c.argument('frontend_endpoints', help='Space-separated list of frontend endpoint names or IDs.', nargs='+', validator=validate_frontend_endpoints)
     with self.argument_context('network front-door routing-rule', arg_group='Forward Routing Rule') as c:
-        c.argument('backend_pool', help='Name or ID of a backend pool.', validator=validate_backend_pool)
+        c.argument('backend_pool', help="Name or ID of a backend pool. It's required to create a Forward routing rule.", validator=validate_backend_pool)
         c.argument('forwarding_protocol', help='Protocol to use for forwarding traffic.')
         c.argument('custom_forwarding_path', help='Custom path used to rewrite resource paths matched by this rule. Leave empty to use incoming path.')
         c.argument('caching', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=False), help='Whether to enable caching for this route.')
diff --git a/src/front-door/setup.py b/src/front-door/setup.py
--- a/src/front-door/setup.py
+++ b/src/front-door/setup.py
@@ -8,7 +8,7 @@
 from codecs import open
 from setuptools import setup, find_packages
 
-VERSION = "1.0.5"
+VERSION = "1.0.6"
 
 CLASSIFIERS = [
     'Development Status :: 4 - Beta',


Test patch:
Repository: Azure/azure-cli-extensions

Issue:
Error firewall network-rule create when trying to create a rule in a Firewall Manager
### Describe the bug

This happens when trying to add rule to a firewall manager resource:
https://docs.microsoft.com/en-us/azure/firewall-manager/overview

**Command Name**
`az network firewall network-rule create
Extension Name: azure-firewall. Version: 0.3.0.`

**Errors:**
```
'NoneType' object is not iterable
Traceback (most recent call last):
python3.6/site-packages/knack/cli.py, ln 206, in invoke
    cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 608, in execute
    raise ex
cli/core/commands/__init__.py, ln 666, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
...
cliextensions/azure-firewall/azext_firewall/custom.py, ln 252, in _upsert_af_rule
    collection_match = next((x for x in collection if x.name.lower() == collection_name.lower()), None)
TypeError: 'NoneType' object is not iterable
```

## 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 network firewall network-rule create -g {} --firewall-name {} --collection-name {} --destination-addresses {} --destination-ports {} --name {} --protocols {} --source-addresses {}`

## Expected Behavior

## Environment Summary
```
Linux-4.15.0-1077-azure-x86_64-with-debian-stretch-sid
Python 3.6.5

azure-cli 2.2.0 *

Extensions:
hack 0.4.2
front-door 1.0.4
azure-firewall 0.3.0

```
## Additional Context

<!--Please don't remove this:-->
<!--auto-generated-->




Discussion:
@MyronFanQiu please help take a look.
add to S169
add to S171

Resolving patch:
diff --git a/src/azure-firewall/azext_firewall/custom.py b/src/azure-firewall/azext_firewall/custom.py
--- a/src/azure-firewall/azext_firewall/custom.py
+++ b/src/azure-firewall/azext_firewall/custom.py
@@ -258,7 +258,7 @@ def _upsert_af_rule(cmd, resource_group_name, firewall_name, collection_param_na
                     item_class, item_name, params, collection_params):
     client = network_client_factory(cmd.cli_ctx).azure_firewalls
     af = client.get(resource_group_name, firewall_name)
-    collection = getattr(af, collection_param_name)
+    collection = getattr(af, collection_param_name, [])
 
     collection_name = collection_params.get('name', '')
     priority = collection_params.get('priority', None)


Test patch:
Repository: Azure/azure-cli-extensions

Issue:
[AKS] az aks get-upgrades --output table fails on extensions
- If the issue is to do with Azure CLI 2.0 in-particular, create an issue here at [Azure/azure-cli](https://github.com/Azure/azure-cli/issues)

### Extension name (the extension in question)
aks-preview

### Description of issue (in as much detail as possible)
Running
```
az aks get-upgrades -g {{RG_NAME}} -n {{CLUSTER_NAME}} --output table
```
fails with

```
preview/azext_aks_preview/_format.py", line 72, in aks_upgrades_table_format
    find_preview_versions(result.get('agentPoolProfiles', [{}])[0])
TypeError: 'NoneType' object is not subscriptable

cli.azure.cli.core.util : Table output unavailable. Use the --query option to specify an appropriate query. Use --debug for more info.
Table output unavailable. Use the --query option to specify an appropriate query. Use --debug for more info.
```

The fix is to not use the agentPoolProfile when formatting the table since the field is nil. We need to update the formatter.

Issue is only when using extensions and the -o table. Works fine on CLI core.
-----




Discussion:
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/aks-pm.
AKS
fyi: the issue is opened by AKS team and tracked internally

Resolving patch:
diff --git a/src/aks-preview/azext_aks_preview/_format.py b/src/aks-preview/azext_aks_preview/_format.py
--- a/src/aks-preview/azext_aks_preview/_format.py
+++ b/src/aks-preview/azext_aks_preview/_format.py
@@ -69,14 +69,12 @@ def find_preview_versions(versions_bag):
             if upgrade.get('isPreview', False):
                 preview[upgrade['kubernetesVersion']] = True
     find_preview_versions(result.get('controlPlaneProfile', {}))
-    find_preview_versions(result.get('agentPoolProfiles', [{}])[0])
 
     # This expression assumes there is one node pool, and that the master and nodes upgrade in lockstep.
     parsed = compile_jmes("""{
         name: name,
         resourceGroup: resourceGroup,
-        masterVersion: controlPlaneProfile.kubernetesVersion || `unknown` | set_preview(@),
-        nodePoolVersion: agentPoolProfiles[0].kubernetesVersion || `unknown` | set_preview(@),
+        masterVersion: controlPlaneProfile.kubernetesVersion || `unknown`,
         upgrades: controlPlaneProfile.upgrades[].kubernetesVersion || [`None available`] | sort_versions(@) | set_preview_array(@) | join(`, `, @)
     }""")
     # use ordered dicts so headers are predictable


Test patch:
Repository: Azure/azure-cli-extensions

Issue:
"az network firewall network-rule delete" note

Hi, 
If there is only one rule in the collection then this command won't let you delete the rule... because then the collection will have no rules, which seems to be a requirement.
**az network firewall network-rule delete**  

`az : AzureFirewallRuleCollection /subscriptions/[removed] must contain at least one rule
At line:1 char:1
+ az network firewall network-rule delete --verbose --firewall-name $fi ...
`

Please add that to the documentation, it confused me for a bit.
Thanks

---
#### Dokumentdetails

⚠ *Bearbeiten Sie diesen Abschnitt nicht. Er ist für die Verknüpfung von Problemen docs.microsoft.com ➟ GitHub erforderlich.*

* ID: a90f7721-6e37-012e-a118-277d5c113f65
* Version Independent ID: c89a7d07-fc9d-748c-d562-2ec9f0295e15
* Content: [az network firewall network-rule](https://docs.microsoft.com/de-ch/cli/azure/ext/azure-firewall/network/firewall/network-rule?view=azure-cli-latest)
* Content Source: [latest/docs-ref-autogen/ext/azure-firewall/network/firewall/network-rule.yml](https://github.com/MicrosoftDocs/azure-docs-cli/blob/live/latest/docs-ref-autogen/ext/azure-firewall/network/firewall/network-rule.yml)
* GitHub Login: @rloutlaw
* Microsoft Alias: **routlaw**


Discussion:
add to S174

Resolving patch:
diff --git a/src/azure-firewall/azext_firewall/_help.py b/src/azure-firewall/azext_firewall/_help.py
--- a/src/azure-firewall/azext_firewall/_help.py
+++ b/src/azure-firewall/azext_firewall/_help.py
@@ -129,7 +129,7 @@
 
 helps['network firewall network-rule delete'] = """
     type: command
-    short-summary: Delete an Azure Firewall network rule.
+    short-summary: Delete an Azure Firewall network rule. If you want to delete the last rule in a collection, please delete the collection instead.
 """
 
 helps['network firewall network-rule list'] = """
diff --git a/src/azure-firewall/setup.py b/src/azure-firewall/setup.py
--- a/src/azure-firewall/setup.py
+++ b/src/azure-firewall/setup.py
@@ -8,7 +8,7 @@
 from codecs import open
 from setuptools import setup, find_packages
 
-VERSION = "0.5.0"
+VERSION = "0.5.1"
 
 CLASSIFIERS = [
     'Development Status :: 4 - Beta',


Test patch:
Repository: Azure/azure-cli-extensions

Issue:
The parameter for --administration-members is incorrectly stated as optional 
For the function 'az powerbi embedded-capacity create', the parameter for --administration-members is incorrectly stated as optional.
If you leave this parameter out, it will give this error:
**BadRequestError: At least one capacity administrator is required**

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: edf4a4a9-8ff1-c276-3e51-d5e83c180879
* Version Independent ID: de63a28e-4d16-2270-595f-1a67f5e682bd
* Content: [az powerbi embedded-capacity](https://docs.microsoft.com/en-us/cli/azure/ext/powerbidedicated/powerbi/embedded-capacity?view=azure-cli-latest)
* Content Source: [latest/docs-ref-autogen/ext/powerbidedicated/powerbi/embedded-capacity.yml](https://github.com/MicrosoftDocs/azure-docs-cli/blob/master/latest/docs-ref-autogen/ext/powerbidedicated/powerbi/embedded-capacity.yml)
* GitHub Login: @rloutlaw
* Microsoft Alias: **routlaw**


Discussion:
powerbi 

Resolving patch:
diff --git a/src/powerbidedicated/azext_powerbidedicated/_params.py b/src/powerbidedicated/azext_powerbidedicated/_params.py
--- a/src/powerbidedicated/azext_powerbidedicated/_params.py
+++ b/src/powerbidedicated/azext_powerbidedicated/_params.py
@@ -41,7 +41,7 @@ def load_arguments(self, _):
         c.argument('sku_name', sku_name_type)
         c.argument('sku_tier', sku_tier_type)
         c.argument('tags', tags_type)
-        c.argument('administration_members', administration_type)
+        c.argument('administration_members', administration_type, required=True)
         c.argument('location', get_location_type(self.cli_ctx))
 
     with self.argument_context('powerbi embedded-capacity update') as c:
diff --git a/src/powerbidedicated/setup.py b/src/powerbidedicated/setup.py
--- a/src/powerbidedicated/setup.py
+++ b/src/powerbidedicated/setup.py
@@ -16,7 +16,7 @@
 
 # TODO: Confirm this is the right version number you want and it matches your
 # HISTORY.rst entry.
-VERSION = '0.1.1'
+VERSION = '0.2.0'
 
 # The full list of classifiers is available at
 # https://pypi.python.org/pypi?%3Aaction=list_classifiers


Test patch: