Skip to content

Commit

Permalink
build 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
felixZdi committed Feb 29, 2024
1 parent a394f98 commit 4f562b1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/azure_function.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
python-version: "3.11"
- name: Install dependencies
working-directory: ./examples/function
run: |
Expand Down
65 changes: 33 additions & 32 deletions examples/function/function_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,41 @@
CertbotResult,
)
from acme_dns_azure.client import AcmeDnsAzureClient

app = func.FunctionApp()

@app.function_name(name="acmeDnsAzure")
@app.schedule(
schedule="%ScheduleAcmeDnsAzure%",
arg_name="acmeDnsAzureTimer",
run_on_startup=False,
)
def main(acmeDnsAzureTimer: func.TimerRequest, context: func.Context) -> None:
utc_timestamp = datetime.datetime.now(datetime.timezone.utc).isoformat()

if acmeDnsAzureTimer.past_due:
logging.info("The timer is past due!")

logging.info("Python timer trigger function ran at %s", utc_timestamp)

acme_dns_config_env_name = "ACME_DNS_CONFIG"

try:
client = AcmeDnsAzureClient(config_env_var=acme_dns_config_env_name)
results: List[RotationResult] = client.issue_certificates()
for rotation in results:
if rotation.result == CertbotResult.FAILED:
logging.exception("Failed to rotate certificate %s.", rotation)
if rotation.result == CertbotResult.SKIPPED:
logging.warning("Skipped to rotate certificate %s.", rotation)
else:
logging.info(rotation)

except Exception:
logging.exception("Failed to rotate certificates")

except ImportError as ex:
import logging

logging.exception("Failed to import")
raise ImportError from ex
app = func.FunctionApp()


@app.function_name(name="acmeDnsAzure")
@app.schedule(
schedule="%ScheduleAcmeDnsAzure%",
arg_name="acmeDnsAzureTimer",
run_on_startup=False,
)
def main(acmeDnsAzureTimer: func.TimerRequest, context: func.Context) -> None:
utc_timestamp = datetime.datetime.now(datetime.timezone.utc).isoformat()

if acmeDnsAzureTimer.past_due:
logging.info("The timer is past due!")

logging.info("Python timer trigger function ran at %s", utc_timestamp)

acme_dns_config_env_name = "ACME_DNS_CONFIG"

try:
client = AcmeDnsAzureClient(config_env_var=acme_dns_config_env_name)
results: List[RotationResult] = client.issue_certificates()
for rotation in results:
if rotation.result == CertbotResult.FAILED:
logging.exception("Failed to rotate certificate %s.", rotation)
if rotation.result == CertbotResult.SKIPPED:
logging.warning("Skipped to rotate certificate %s.", rotation)
else:
logging.info(rotation)

except Exception:
logging.exception("Failed to rotate certificates")

0 comments on commit 4f562b1

Please sign in to comment.