Skip to content

Commit fc62583

Browse files
author
Max Dymond
committed
Switch from using bash scripts to python scripts for creating resources
1 parent f02d03b commit fc62583

File tree

17 files changed

+918
-417
lines changed

17 files changed

+918
-417
lines changed

.flake8

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
11
[flake8]
22
max-line-length = 88
33
extend-ignore = E203
4+
exclude =
5+
.python_packages
6+
.venv
7+
.git
8+
__pycache__
9+
.mypy_cache
10+
11+
ignore =
12+
# Default ignores
13+
E121,E123,E126,E226,E24,E704,W503,W504
14+
15+
# Auto-fmt compatibility
16+
# Whitespace before ':' | NOT PEP8 COMPLIANT
17+
E203,
18+
# Allow long lines if needed | BLACK HANDLES CODE FORMATTING
19+
E501,
20+
# Multi-line docstring summary should start at the first line
21+
D212,
22+
23+
# Allow looser flake8-docstrings / pydocstyle restrictions
24+
# One-line docstring should fit on one line with quotes
25+
D200,
26+
# First line should end with a period
27+
D400,
28+
# First line should be in imperative mood
29+
D401,
30+
31+
# Subprocess module imported. Warning to be careful only.
32+
S404,
33+
# Subprocess used without shell=True. Warning to be careful only.
34+
S603,

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
run: |
1919
python -m pip install --upgrade pip poetry
2020
poetry install
21-
- name: Analysing the code with pylint
22-
run: |
23-
poetry run pylint $(git ls-files '*.py')
2421
- name: Analysing the code with mypy
2522
run: |
2623
poetry run mypy $(git ls-files '*.py')
24+
- name: Analysing the code with flake8
25+
run: |
26+
poetry run flake8 .

README.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,45 @@ an Azure Function App to keep it up to date. For use with
66

77
# Getting Started
88

9+
## Required tools
10+
11+
- `poetry` and `poetry-plugin-export`: required for running the creation commands and exporting dependencies to requirements.txt format.
12+
- Poetry installation instructions are available at https://python-poetry.org/docs/#installation
13+
- Once poetry is installed, run
14+
```bash
15+
poetry self add poetry-plugin-export
16+
```
17+
to install `poetry-plugin-export`.
18+
- Azure CLI
19+
- Installation instructions available at https://learn.microsoft.com/en-us/cli/azure/install-azure-cli
20+
21+
- Docker (when not using shared key access from the function app to the storage container)
22+
- Installation instructions available at https://docs.docker.com/engine/install/
23+
924
## Basic usage
1025

1126
To create a new Debian package repository with an Azure Function App, run
1227

1328
```bash
14-
./create_resources.sh <resource_group_name>
29+
poetry run create-resources <resource_group_name>
1530
```
1631

1732
with the name of the desired resource group. The scripting will autogenerate a
1833
package repository name for you - `debianrepo` followed by a unique string to
1934
differentiate it across Azure.
2035

21-
If you wish to control the suffix used, you can pass the `-s` parameter:
36+
If you wish to control the suffix used, you can pass the `--suffix` parameter:
2237

2338
```bash
24-
./create_resources.sh -s <suffix> <resource_group_name>
39+
poetry run create-resources --suffix <suffix> <resource_group_name>
2540
```
2641
which will attempt to create a storage container named `debianrepo<suffix>`.
2742

2843
By default all resources are created in the `eastus` location - this can be
29-
overridden by passing the `-l` parameter:
44+
overridden by passing the `--location` parameter:
3045

3146
```bash
32-
./create_resources.sh -l uksouth <resource_group_name>
47+
poetry run create-resources --location uksouth <resource_group_name>
3348
```
3449

3550
## No shared-key access / Managed Identities
@@ -42,7 +57,7 @@ compiled and packed appropriately).
4257
To create a new Debian package repository which uses Managed Identities, run
4358

4459
```bash
45-
./create_resources_nosharedkey.sh [-s <suffix>] [-l <location>] <resource_group_name>
60+
poetry run create-resources --no-shared-key [--suffix <suffix>] [--location <location>] <resource_group_name>
4661
```
4762

4863
This creates an additional blob container (`python`) in the storage account to
@@ -65,9 +80,13 @@ The function app works as follows:
6580
single `Package` file, which is then uploaded. A `Packages.xz` file is also
6681
created.
6782

68-
As the function app works on a Consumption plan it may take up to 10 minutes for
69-
the function app to trigger and regenerate the package information. In practice,
70-
the eventGridTrigger is triggered very quickly.
83+
## Speed of repository update
84+
85+
The function app triggers at the speed of an Event Grid trigger running in Consumption
86+
mode; in the worst case this means triggering from a Cold Start. In practice
87+
the repository is updated within 1 minute.
88+
89+
# Project
7190

7291
## Contributing
7392

create_resources.sh

Lines changed: 0 additions & 125 deletions
This file was deleted.

create_resources_nosharedkey.sh

Lines changed: 0 additions & 147 deletions
This file was deleted.

0 commit comments

Comments
 (0)