Select Page

Azure Function timer triggers

Deep joy working with Azure Function apps, and using timer triggers this last few weeks.

I’ve been working on a set of Azure Functions that fire on a schedule, to read information from across the Azure environment, and write the results to Cosmos DB. Simple enough.

The trigger is set as a Timer:

image

The timer takes an NCRONTAB format for when it fires.

The various pieces of documentation are pretty clear, and I’ve got a lot of familiarity with CRON running on Linux.

My initial schedule was 0 0 */8 * * * – which should fire every 8 hours.

image

Instead – some really variable and unreliable results. I found "8-ish" hours between triggers to be best case, often the whole function stopped firing. Restart the function, and "8-ish hours" later it fired.

After a bunch of reading and testing, I changed the schedule to 0 0 0/8 * * * – which fires at 00Z, 08Z, 16Z – so every 8 hours, but locked to midnight, 8.00am and 4.00pm UTC.

image

So far – so good.

This was a good NCRONTAB expression tester: NCrontab Online Expression Tester Evaluator (swimburger.net)

Hosting updates again

This blog (and several others) have been Azure hosted, on a monolithic SLES 15 virtual machine for a good few years.

I seem to have done the rounds on various flavours of Azure hosting. App Service with Project Nami, straight IaaS (like today), App Service with WordPress as a Microsoft provided service.

This last weekend I pulled the database out from the various blog VMs and moved that to a PaaS MySQL environment. It’s cheap, burstable, and seems more than performant for what I need. The other cool feature is VNET isolation – so the database engine is only accessible from my infrastructure running in Azure.

Access to the local Enphase Envoy API through code

Introduction

In April 2022 I had a PV system installed, with a local Enphase Envoy as part of the configuration.

The Enphase Envoy acts as a management gateway for the Enphase system. Collecting, storing and forwarding data to Enphase for the consumer Enlighten datapool and application.

My installation consists of an IQ Combiner; but I believe these instructions are valid for any Envoy running software greater than version 7. At the time of writing my Envoy is running D7.0.85.

Some history

I was interested in the raw data coming from the PV system. During vendor selection I reviewed the access and APIs available; and Enphase seemed to have a good mix of capabilities.

At some point in late 2021/early 2022 access to a local Envoy gateway was changed to require a JWT access token. This caused many home automation and data logging integrations to break. The documentation from Enphase showed how to interactively get the token and login. I found no documentation on doing this automatically through code.

After much reading, reviewing multiple blogs and github repos, and trial and error – I have this now working.

Authentication flow

Firstly, there’s a lot of head scratching on this approach from Enphase. Yes – it protects access behind a token, but it’s all intended for interactive work. I can only surmise that the market for this is not the home integrator or API data scraper. I see Enphase pushing that persona towards the Enlighten API v4 – which has a different set of issues (which I’ll write about in the future).

So the flow:

The third step of this, posting the JWT to /auth/check_jwt, does not seem to be documented anywhere.

Also, and most troubling, the JWT itself is returned as part of the body of a html page. Some regex is needed to extract the specific text string. This has risk in the event that the html document structure changes in the future.

I posted a sample PowerShell script here.

Using this approach, I now have data being pulled from the local IQ Combiner, parsed, posted to a NoSQL database, and then graphed.

COVID – wrapping up after 110 weeks

COVID-19, the disease caused by the SARS-CoV-2 virus, is not gone. People around the globe are still getting sick, having long term issues from "long COVID", and dying.

However, after 110 weeks of blogging, the news cycle has moved on.

Over 11 billion vaccines and boosters have been given. The global distribution is not fair or equitable.

Vaccination, masking and empathy are polarising, political, issues. The scars will be felt for decades.

So here we are. Over 6 million deaths, multiple waves of disease. Lockdown, disruption, anger, fear.

I predict these events:

  • annual combined "flu and Covid" shot by late 2022
  • continued politicisation of vaccination, especially in the US
  • continued cases across the globe
  • emergence of new variants, several of which will break out
  • a winter 2022/2023 wave, with no restrictions or mask mandates

On the positive side:

  • Covid vaccine development and technology innovation will lead to breakthrough prevention and treatment regimes for multiple diseases
  • an approved vaccine for under 5s
  • safe, cheap and effective vaccination supply chains across the globe.

Signing off for the final time on this subject.

–Martin

image

 

image

COVID – week 110 – April 18 – April 24

I honestly forgot to write two weeks of updates. Locally we attended the Seattle International Film Festival, in-person, masked. I received a notification of brief exposure at the Sunday closing event. New cases are still working through the under fives, their teachers, their carers and families.

Globally the number of cases is down 25% week on week.

The Seattle Times dashboard is now gone. Replaced with a trends graphic.

image

This time 2021 – "concerns about the one variant that breaks out" was a warning around Omicron, six months early.

This time 2020 – drinking disinfectant became a thing, a precursor to all of the other quack remedies. Negative oil prices. Fake anti-lockdown protests.

  The Seattle Times
18 Apr here
19 Apr here
20 Apr here
21 Apr here
22 Apr here
23 Apr here
24 Apr  

https://www.theguardian.com/world/series/coronavirus-live

https://www.seattletimes.com/tag/coronavirus/

COVID – week 109 – April 11 – April 17

Weekly summaries from here on out. I’ll share the news links, and comment on anything unusual or newsworthy.

Multiple new variants are spreading quickly. XE, BA.2.12, BA.2.12.2 and others. Widespread numbers of cases still breaking through. Fines issued in UK "Partygate". War, war crimes, and sanctions move the pandemic way beneath the fold. Testing sites, free tests and contact tracing is a fraction of what it was a year ago.

This time 2021 – pandemic fatigue. Weariness of lockdown, masks, regulations. Cases surging across Europe and the US as a result.

This time 2020 – we decided not to attend a Sounders soccer game, which in retrospect was a good move. Kids are in the routine of "school from home".

 

  The Seattle Times
11 Apr here
12 Apr here
13 Apr here
14 Apr here
15 Apr here
16 Apr here
17 Apr  

https://www.theguardian.com/world/series/coronavirus-live

https://www.seattletimes.com/tag/coronavirus/

COVID – week 108 – April 4 – April 10

Weekend – the BA.2 strain is dominant. Locally there are a lot of cases close to home. The Washington State cases have picked up.

Friday – Federal mandate for vaccination is upheld. Masks, vaccination and everything related are starkly political.

Thursday – two years after the panic about PPE, tests and government support for business, the fraud cases are starting to come to court. So much grift, malpractice and just straight theft.

Wednesday – Covid cases soaring in the UK. NHS pressure. Second booster done. Yay.

Tuesday – much concern about Omicron/BA.2 spread in China. Shanghai on lockdown.

Monday – fourth shot/second booster booked for mid-week.

This time 2021 – Washington State picking up new cases. UK emerging from a major wave and lifting restrictions.

This time 2020 – UK NHS at near breaking point. Boris Johnson with Covid. Visible changes: no planes in the sky. Less roadnoise.

  The Seattle Times
4 Apr here
5 Apr here
6 Apr here
7 Apr here
8 Apr here
9 Apr here
10 Apr  

https://www.theguardian.com/world/series/coronavirus-live

https://www.seattletimes.com/tag/coronavirus/

COVID – week 107 – March 28 – April 3

Weekend – locally, cases are low, hospitalisations are low, and the general population seems to think the pandemic is over. Anecdotally – Covid is still taking kids out of school.

Friday  – as war continues to dominate the news cycles, the continued Omicron surge in South Korea, Hong Kong SAR and PRC is generally unreported. The growing number of cases in the UK and now the US is not getting any attention. Meanwhile the number of hospitalised in the US is at a pandemic low.

Thursday – UK stopping free tests, now similar to US in tests being sold in retail stores.

Wednesday – How to Survive a Pandemic looks to be the latest in documentaries giving narrative of the pandemic.

Tuesday – FDA approves second boosters for 50+. UK Partygate fines issued.

Monday – Shanghai, PRC in lockdown.

This time 2021 – the start of a new wave, Covid spreading faster than vaccination.

This time 2020 – blood draw to see if I had early Covid in January (I did not), lockdowns being relaxed in the US.

  The Seattle Times
28 Mar here
29 Mar here
30 Mar here
31 Mar here
1 Apr here
2 Apr here
3 Apr  

https://www.theguardian.com/world/series/coronavirus-live

https://www.seattletimes.com/tag/coronavirus/

COVID – week 106 – March 21 – March 27

Weekend – positive cases are down dramatically since the start of the year. Unclear how many tests are actually being run now. UK cases keep trending up; disastrous timing of all protections being lifted, along with a surge of BA.2. It’s a balancing act to what happens next in the US.

image

Friday – much discussion about vaccination rates, boosters, a fourth shot – and the timing of any fourth shot. Does this become an annual combination ‘flu and covid’ shot. I mentioned this two years ago.

Thursday – BA.2 keeps popping up as the next variant of concern. The "dance" of the Hammer and The Dance.

Wednesday – US airlines ask for mask mandates in airports and on planes to be lifted.

Tuesday – no funding in the budget for more COVID testing and boosters/vaccinations. BA.2 variant is now 25% of cases in Washington state.

Monday – New covid wave in the UK. Big jumps in positive cases. That peak is as bad as the end of 2021.

image 

This time 2021 – another wave. Spring break, no masks, variants.

This time 2020 – Fauci predicts 100-200k deaths in the US. (it’s now 1M), military field hospitals being built in Seattle, 3.3M file unemployment.

  The Seattle Times
21 Mar here
22 Mar here
23 Mar here
24 Mar here
25 Mar here
26 Mar here
27 Mar  

https://www.theguardian.com/world/series/coronavirus-live

https://www.seattletimes.com/tag/coronavirus/