Skip to main content

Logic Apps

The Logic Apps are the orchestration layer behind Three Bears Alaska. They send the purchase orders and tax exemption reports, watch the replication process, and provide a couple of shared utilities the other flows call into.


Index​

ResourcePurposeStatus
email-notifierShared email sender used by the other flowsEnabled - important
FIT-Threebears-Email-Sender-1.00Sends the WOG Word template emails - note the similarly named app on the client tenantEnabled
throw-exceptionShared error-exit helperEnabled
SmartPO-submit-po-prod_v1-2-0Sends SmartPO purchase orders - the live oneEnabled, in use
SmartPO-submit-po-prod_v1-1-2Previous production version, kept as referenceEnabled, nothing calls it
SmartPO-submit-po-devDeveloper version, used from localhostEnabled
daily-tax-exemption-report-generationBuilds and sends the daily reportEnabled
monthly-tax-exemption-report-generationBuilds the monthly reportEnabled - email send fails by design
daily-db-replication-monitorAlerts us if replication has stalledEnabled
service-account-key-rotation-reminderMonthly reminder to cycle keysEnabled - likely removable
delete-sharepoint-fileSharePoint cleanupEnabled, but not doing anything

Shared Utilities​

Two Logic Apps exist purely to be called by the others, so that common behaviour isn't rebuilt in every flow.

email-notifier​

The most important of the shared apps. It takes content, structures it properly, and sends it as an email from the SmartPO admin account - a Microsoft account Three Bears Alaska created for the purpose.

It is used much more like a function than a workflow: other Logic Apps hand it parameters and it sends the resulting email. Most outbound mail across these flows goes through it.

FIT-Threebears-Email-Sender-1.00​

There are two similarly named email senders, on different tenants, doing different jobs. Do not treat them as the same resource:

  • Ours, the one listed here, sits in the ThreeBearsAlaska resource group on our tenant. It sends the Word template emails for the legacy Warehouse Order Guide, and belongs to WOG.
  • Theirs, separately created on the Three Bears Alaska tenant, is one piece of the email sending flow

throw-exception​

A deliberately tiny Logic App. It provides a way to error out of a Logic App without the run itself registering as a failure. Because that pattern would otherwise be repeated everywhere an error could occur, Clay pulled it into its own Logic App, and the other flows call it at their error branches.

Minor, but worth knowing why it exists before assuming it's dead weight.

Purchase Orders​

Submit PO​

The Submit PO Logic Apps are what actually deliver a SmartPO purchase order. They call the Azure Function that builds the purchase order file, then send it on to the right recipients. See SmartPO for the ordering flow that triggers them.

Beyond sending, each one does a significant amount of work:

  • Polling the database for the items on the order
  • Verifying the order is valid and makes sense to send before anything goes out
  • Error handling, which reports failures back to us whether the fault is on our side or theirs

There are three versions, all enabled:

ResourceRole
SmartPO-submit-po-prod_v1-2-0The live one. It is the one with regular runs.
SmartPO-submit-po-prod_v1-1-2The previous production version. Reference only - nothing calls it, so it costs nothing to keep.
SmartPO-submit-po-devThe developer version, used when running against localhost

SmartPO-submit-po-prod_v1-1-2 is kept deliberately. It preserves how permissions and identity were configured, so there is a known-good copy to compare against before changing settings on the live one.

SmartPO-submit-po-dev mirrors the live one closely, except the checks for dev mode are hardcoded to route to the dev side. It's worth reading through before working on any of these.

Tax Exemption Reporting​

Both report generators call the Azure Function that builds the report files. See Tax Exemption for how the underlying data is captured and how the reports are used.

daily-tax-exemption-report-generation​

Builds the daily tax exemption report and sends it to our email and to the Three Bears Alaska finance email.

Note: it is not certain the report still goes to Three Bears Alaska. Mike may have asked for that recipient to be turned off at some point since they primarily use the monthly report. Check the Logic App's current recipients to confirm.

monthly-tax-exemption-report-generation​

Runs on the 1st of each month and does for the month what the daily app does for the day, building the month's report through the same Azure Function and reporting success or failure back to us.

The monthly report has outgrown email. Only two stores, 119 and 120, use tax exemption, but the volume of exemptions per month is enough that the attachment is rejected and the send fails. The flow writes the report to SharePoint as part of its process, and Three Bears Alaska collects it from there. The failing send is known and accepted rather than fixed.

Monitoring & Maintenance​

daily-db-replication-monitor​

Checks a frequently-changing table in the database once a day to confirm something has been written within roughly the last six hours. If it has, replication is working. If it hasn't, the app emails us an error.

Occasionally there is a genuinely quiet six hours and it flags a false positive. That tradeoff is accepted, because if replication fully fails this catches it the same day. See the Replication entry in the Glossary for why the replication process is fragile.

service-account-key-rotation-reminder​

A monthly reminder to cycle the Google service account keys, which are tied to the Firebase logins.

Clay set this up out of concern about key rotation cadence, though the keys don't need cycling anywhere near that often - roughly once a year is where the conversation landed, while the reminder still fires monthly. The reminder is usually not acted on, though it does prompt the occasional rotation.

This one could probably be deleted.

Not In Use​

delete-sharepoint-file​

Intended to clean up SharePoint files and was partway along, but never became a priority worth finishing. It is not doing anything today, though it is still showing as Enabled in Azure.

Worth considering alongside the monthly tax exemption reports, which accumulate in SharePoint indefinitely by decision.