Saturday 14 January 2023

APIM Logging

Overview: Azures API Management is a big service, it is worth understanding the logging capability so you can effectively analyse traffic.

Thoughts:

  • Multiple App Insights can be setup with default logs going to a specific App Insights.
  • Each API can be overridden to log to any of the API's added to API.
  • The old "Classic" App Insights, stored data internally, whereas the new "workspace-based" app insights", I think of it it as "V2 App Insights connected to a Log Analytics", the new data is stored in the workspace.
  • If you upgrade App Insights, the results blend from two storage locations, the old data stored internally with App Insights and the new data stored within Log Analytics - if you query Log analytics, you only see the new log analytics data.
  • Security for App Insights should be done at the Resource Group (RG) level, ther are AppInsight roles for use at RG level, if the workspace is on a different resource group to the app insights connected instance, ensure you sort out the permssions in both RGs.
  • Open Telemetary project is making strides forward, and for API's it will be great.

Problem: I recently migrated a customer Dev, Test, Appearance, Pre-prod and Production (Not yet) to use the AppInsights instance running on Log Analytics (sometimes refereed to as V2).  Logging wasn't work correctly.


Initial Hypothesis: I have complicated resource groups differing crossing DTAP boundaries.  By default, APIM has a logging catch all setup per APIM instance and then specific API's settings are changed to log to specific App Insights.

Steps:

My AppInsights instance was to rename the old classic type AppInsights e.g. "appinsights-dev" becames "appinsights-dev-delete".

Create a new AppInsights instance using the V2 Log Analytics option  and name it the original name "".  The client opted for the name to be the same.  It would be simpler to give it a name like "appinsights-dev02".  The clients also wanted to use a shared Log Analytics instance per env e.g. "loganalytics-dev-shared".






Monday 2 January 2023

Power Platform Competitors

Overview:  I like Power Platform, but there are other options out there.  Most products that are competitors cover a piece of what the Power Platform covers.

Mendix: A friend has used Mendix and they were not a fan.  I have played around and I like the product.  I certainly haven't found it's limitations but it feels straight forward and logical.  Easy to learn. 

Cons: 

  1. The publishing is very slow
  2. Free version you have to use Mendix subdomain.  Basic plan is $50/month, for my small demo, it a high price,


Outsystems:

Airtable:  Has lots of templates and easily connects to various data sources.  Easy to extend or build apps on the platform. Provides storage and low code apps.  It's like having Dataverse and Power Apps.  There are pre-built templates to get the team off to a start.

Nintex: Bought K2 and have a long history in workflows (workflows for SharePoint and O365), screen/form generation and form building.  If your company uses Nintex then worthwhile but I wouldn't use it for new projects or if the team does not have significant experience.

UiPath: RPA tool. A strong tool for automation, from a desktop automation and recording piece I feel UiPath is ahead of Power Automate Desktop (PAD).  Both UiPath and Power automate allow for attended and unattended runs.  PAD is part of Power Automation Premium or Power Automate Process licences. Automation Anywhere, and Blue Prism are other big players in the RPA space.

Postman Workflows: Bit of a dark horse but people love postman and i think this may become a interesting option for Rapid development.

Amazon:  AWS has various services that allow for Low Code solutions.  "Amazon Honeycode" is kind of like Model driven & Canvas apps, that can call Lambda's.  Lamda's are the same service as Azure Functions on AWS.  AWS Honeycode has predifined templates as staring points so I feel it is more like Salesforce's low code approach. This allows the developer to break out an write complex logic or persist the database in S3 storage.  "Amazon QuickSight" works like Power BI for reporting on solution data.

Salesforce Lightening: Allows for building custom apps and utilising Salesforce CRM and it's data. 

Retool: Good set of connectors to API's.


Appian: 

OutSystems: 

Friday 30 December 2022

Testing Power Apps using Microsoft Playwright with C#

Overview: I am using a C# Console app to run my power Apps to verify that it is working correctly.

Approach:  I'm not using NodeJs but I'll use C# and add it into my devOps pipelines.  I assume you have VS Code installed (you need the C# extensions, I have kept my notes at the bottom of the post).  I'm using .NET 6 core SDK and the Microsoft.Playwright package.  I'm not using any of the .NET testing frameworks to keep it simple.

Tips: Playwright by default use headless browser testing, I want the test to use my local JWT that I have stored against my Chrome browser.  If I tell Playwright to use show the browser i.e., headless=false, it logs me in using my cached credentials.  You should parameterise the login and store the username/pswd somewhere secure like a key vault. 

Code Example


Replace the C# code in the console as I have done above, and hit F5 (Run>Debug).  The test logs me into the Canvas app and returns the Title of the page. 

Note:  I like the Canvas app testing feature but this is better as I can easily add testing to my CI/CD pipelines, tooling and recording is better and there are more ways I can use the Playwright approach.  

Notes for installing Playwright on VSCode to use C#

1. Install VS Code and add the following two extensions


2. Open the VS Code terminal, create a C# Console app using .NET6, add the reference to the Playwright package, install the headless browsers against you profile (only needed once per machine). 
3. Write and run the tests.  Tip: It's easier to record the code and then add it to the C# console.

Note: It's worthwhile using NUnit as it's much easier to test than doing it the way I've done it here.

Playwright using the NUnit framework:



Tuesday 6 December 2022

Using the OpenAI PowerFx language helper leading into building a Tax chatbot using Power Apps (No model training)

I had some time today, and I've been hearing a lot about OpenAI/GPT-3, so I thought I'd have a look around and wow it's good.  There are so many uses and it's just easy to use.

For instance, Power Apps uses PowerFx which is a simple language that Microsoft had added the "Ideas" are to that helps you build PowerFx code.  Honestly I found it extremely irritating when it was released recently but after reading more on Open AI I to take a closer look and it definitely is a great idea.



Thoughts:  I don't memories code so I feel this is a great tool for citizen and professional developers.  I think it will get a lot of attention and improve over time and become a key part of PowerFX and app development.

More Info:

https://learn.microsoft.com/en-us/power-apps/maker/canvas-apps/power-apps-ideas

OpenAI - Took less than an hour to setup the demo

The Power Platform has a Premium Connector to use the OpenAI API's.  Robin Rosengrun has a demo and built and published a connector. 

I spent some time playing around with the OpenAI GPT-3 API using the "davinci-002" engine in a Power App connector.    

First search data result is correct
This is completely wrong, although HMRC have amended the go live date many times.  I was hoping for "6 April 2024"

The third question result is good - but could be better.

Sunday 20 November 2022

ARM Templates vs Bicep vs Terraform vs Pulumi

ARM templates, they are instructions that run against Azure to create resources.  

ARM templates will update settings such as tags when added, deleted or updated using json.
If a dependent resource is called e.g. storage, the ARM template creates the storage and if variables are supplied it shall use them.  Removing or changing the dependency won't update the dependent resource, it will create a new storage resource and point to the new storage. 
Note: Templates don't remove dependent resources if they are pulled from the ARM template. It will not upgrade to the latest instructions. I.e. it does not take the infrastructure to desired state config (DSC).
There is a DSC modules for ARM templates, but i believe this is more for VM's.

Bicep is a domain specific language which is DSC, it's json and way easier to build up your infrastructure.
Bicep will run ARM templates "under the hood" and provide the full desired state.  Bicep is a Microsoft Azure only concept and can be used for private cloud infrastructure.  

Terraform is an open source DSL to build IaC, and it works on AWS, Azure and GCP (and Oracle ...).
Terraform is created by HashiCorp, HashiCorp have an amazing tooling set that uses the Terraform language to build, and changes Infrastructure.  Uses the HCL Language.

AWS CloudFormation is the native way to build IaC on AWS.  Supports json and YAML.

Pulumi is an exciting competitor to Terraform.  Can us multiple languages and easy to write new modules.  Code is compiled and uses appropriate cloud API's to create IaC.   Compare Terraform to Pulumi.  Uses TypeScript/JS, Python or C#.  Pulumi is Open Source, and there is a free tier SaaS offering on Pulumi Cloud.

Common Dev setup could be: TypeScript with Pulumi created using VS code npm for packages.  
Pulumi needs a program yaml file, tells it the language to use and other setup.  2 types of providers: Terraform bridge providers and native provides.  There are over 150 connectors most are Terraform .  Support multiple languages e.g. TypeScript, C#, Python Java, YAML.  Easy to integrate into CI/CD/DevOps.  Pulumi is basically a command line tool that can be called from DevOps including Pulumi Cloud.


Pulumi (Any) vs Terraform (HCL lang) vs AWS: CDK (TS, C#, Py, Go, Java) or CloudFormations (YAML)  vs Azure: ARM/Bicep (DSL).

Nutanix - new to me but looks like VMWare using IaC for multi-cloud basically Terraform but manage and monitor.  Very likely to be wrong here.

Summary:
Use what the organisation uses, Bicep is great if you only are using Azure, and for smaller work/specific DTAP IAC using ARM templates is a well trodden route.  If the organisation wants multi-cloud (do not take multi-cloud lightly) then Terraform and even Hashicorp using Terraform is the way to go.  Terraform and Pulumi are for multi-cloud/run at a higher level than CloudFormation, ARM/Bicep.

Note: Resist multi-cloud at all costs, I've heard ridiculous reasoning like we don't want to be tied to only AWS or Azure.  That's cool but costs go up exponentially with multi-cloud, it's not even the infra that costs, it's the management overhead and testing/verification.  Which parts can be changed.  A business would need a really good reason to go to multiple vendors.

Power Apps issue with OptionSets Syntax irregularity

Problems: OptionSets in Power Apps (Canvas apps can be a little nasty to work with, today I took a couple of hours  trying to use an OptionSet to filter results.  This should have taken 5 minutes but there is a weird behavior when using switch or if statements to dynamically filter using options sets.

Hypothesis:  using if/switch logic when using an OptionSet in Dataverse to filter results in the code being change/interpreted incorrectly at run time. 

Resolution:  Use a variable to hold the dynamic OptionSet choice as shown above.  I hope this post can help anyone having issues relating to Option sets for filtering and updating.

In the example below I show how to Insert a new Row using a Patch where the row contains an OptionSet.  It's ugly but, it works...

On the Save...
Set(orgType, Blank());
If(
    <ddlOrgType.Value> = "Personal", Set(orgType, 'Org Type'.'Sole Trader'),
    <ddlOrgType.Value> = "Incorporated", Set(orgType, 'Org Type'.'Limited Company'),
    <ddlOrgType.Value> = "Partnership", Set(orgType, 'Org Type'.'Partnership')
    );
Insert the new row for Subject

Sunday 13 November 2022

Deploying a Canvas App direct to mobile devices

Overview:  Canvas apps have a feature called "Wrap" that can take a canvas app via a solution and allow it to be access naively on iOS and Droid.  This allow users to open the canvas app without going thru the Power Apps client on their mobile device.  The apps can be shipped using the app stores/marketplace or Microsoft Intune for enterprise deployment.

Enable the feature in your dev/un-managed environment using the "Power Platform Admin centre":

There is a great wizard that takes care of a lot of the underlying work such as registering the app in Azure Portal AAD.

Use the Wrap wizard (you'll need a lot of access rights on the Power Platform and Azure Portal)
Pick your package types, this post outlines the full process for Android (apk). Below shows the iOs file needed for the Apple store but you can distribute using InTune.