Repository: Azure/azure-cli-extensions

Issue:
Azure Firewalll CLI -  https become http
- 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)
Azure Firewall


### Description of issue (in as much detail as possible)

Creating an app rule with the cli seems to interpret:

--protocols "Https=443" "Http=80" 

As:

--protocols "Http=443" "Http=80"

i.e. all rules end up as http - you can hand edit them in the portal to be correct.

-----


Azure Firewalll CLI -  https become http
- 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)
Azure Firewall


### Description of issue (in as much detail as possible)

Creating an app rule with the cli seems to interpret:

--protocols "Https=443" "Http=80" 

As:

--protocols "Http=443" "Http=80"

i.e. all rules end up as http - you can hand edit them in the portal to be correct.

-----




Discussion:
https://docs.microsoft.com/en-us/cli/azure/ext/azure-firewall/network/firewall/application-rule?view=azure-cli-latest#ext-azure-firewall-az-network-firewall-application-rule-create
https://docs.microsoft.com/en-us/cli/azure/ext/azure-firewall/network/firewall/application-rule?view=azure-cli-latest#ext-azure-firewall-az-network-firewall-application-rule-create

Resolving patch:
diff --git a/scripts/ci/update_index.py b/scripts/ci/update_index.py
new file mode 100644
--- /dev/null
+++ b/scripts/ci/update_index.py
@@ -0,0 +1,68 @@
+# --------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# --------------------------------------------------------------------------------------------
+
+import hashlib
+import json
+import re
+import sys
+import tempfile
+
+from util import get_ext_metadata, get_whl_from_url
+
+NAME_REGEX = r'.*/([^/]*)-\d+.\d+.\d+'
+
+
+def get_sha256sum(a_file):
+    sha256 = hashlib.sha256()
+    with open(a_file, 'rb') as f:
+        sha256.update(f.read())
+    return sha256.hexdigest()
+
+
+def main():
+
+    # Get extension WHL from URL
+    whl_path = None
+    try:
+        whl_path = sys.argv[1]
+    except IndexError:
+        pass
+    if not whl_path or not whl_path.endswith('.whl') or not whl_path.startswith('https:'):
+        raise ValueError('incorrect usage: update_script <URL TO WHL FILE>')
+
+    # Extract the extension name
+    try:
+        extension_name = re.findall(NAME_REGEX, whl_path)[0]
+        extension_name = extension_name.replace('_', '-')
+    except IndexError:
+        raise ValueError('unable to parse extension name')
+
+    extensions_dir = tempfile.mkdtemp()
+    ext_dir = tempfile.mkdtemp(dir=extensions_dir)
+    whl_cache_dir = tempfile.mkdtemp()
+    whl_cache = {}
+    ext_file = get_whl_from_url(whl_path, extension_name, whl_cache_dir, whl_cache)
+
+    with open('./src/index.json', 'r') as infile:
+        curr_index = json.loads(infile.read())
+
+    try:
+        entry = curr_index['extensions'][extension_name]
+    except IndexError:
+        raise ValueError('{} not found in index.json'.format(extension_name))
+
+    entry[0]['downloadUrl'] = whl_path
+    entry[0]['sha256Digest'] = get_sha256sum(ext_file)
+    entry[0]['filename'] = whl_path.split('/')[-1]
+    entry[0]['metadata'] = get_ext_metadata(ext_dir, ext_file, extension_name)
+
+    # update index and write back to file
+    curr_index['extensions'][extension_name] = entry
+    with open('./src/index.json', 'w') as outfile:
+        outfile.write(json.dumps(curr_index, indent=4, sort_keys=True))
+
+
+if __name__ == '__main__':
+    main()
diff --git a/src/azure-firewall/azext_firewall/_validators.py b/src/azure-firewall/azext_firewall/_validators.py
--- a/src/azure-firewall/azext_firewall/_validators.py
+++ b/src/azure-firewall/azext_firewall/_validators.py
@@ -17,7 +17,7 @@ def validate_application_rule_protocols(namespace):
         item_comps = item.split('=')
         if len(item_comps) != 2:
             raise usage_error
-        protocol_list.append({'type': item_comps[0].lower().capitalize(), 'port': item_comps[1]})
+        protocol_list.append({'protocol_type': item_comps[0].lower().capitalize(), 'port': item_comps[1]})
     namespace.protocols = protocol_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.1.0"
+VERSION = "0.1.1"
 
 CLASSIFIERS = [
     'Development Status :: 4 - Beta',


Test patch: