Posts

terraform using different providers

 We can easily setup our terraform to support different providers. This is useful when we like to setup our resources using different subscription.  modules/storage/main.tf resource "azurerm_storage_account" "old_storage" {   name                     = var . storage_name   resource_group_name       = " mytest-kv-rg "   location                 = " australiaeast "   account_tier             = " Standard "   account_replication_type = " LRS " } variable "storage_name" {   type = string } And then we have this as our main.tf  # The default provider (Implicitly used if no provider is specified) provider "azurerm" {   features {}   subscription_id = "aaaaaaaaaaaaaaaaaaaaa " # Subscription A } # The aliased provider provider "azurerm" {   alias         ...

Error: unable to build authorizer for Resource Manager API: could not configure AzureCli Authorizer: the provided subscription ID "xxxxxxxxx" is not known by Azure CLI

Ran into this error trying to work with terraform - turn out the simplest solution is just to do "az login" 

terraform test - creating and asserting unit test in terraform

  In this example, we will be creating a simple storage account and then testing it with terraform test. Let start off with the following scripts  variable "account_name" { type = string } variable "resource_group_name" { type = string } variable "location" { type = string } variable "environment" { type = string description = "The environment for the deployment." validation { # The condition must return true for the variable to be accepted. condition = contains ([ "dev" , "staging" , "prod" ], var . environment) # This is the message printed to the screen if the condition is false. error_message = "Validation Error: The environment must be 'dev', 'staging', or 'prod'." } } resource "azurerm_storage_account" "this" { name = var . account_name resource_group_name...

microsoft entra - creating an open client (without password)

Image
We can use Entra to create a open client where is often use for mobile app that are distributed over to others. To do that goto App Registration -> Create a new App Registration  Please note that we have set valid redirect url to 'https://localhost'. We do not need a local web server to be running for our test.  Next, we will add relevant scope.  Let's test out our client here using Postman. Please provide the require configuration as shown here:  Auth URL :-  https://login.microsoftonline.com/tenant-id/oauth2/v2.0/authorize Access Token Url :-  https://login.microsoftonline.com/tenant-id/oauth2/token Client ID:  (should replace with your client id) Client Authentication: Send Client Credential in Body) And if you hit "Get new access token" - you should get a new token  

Postman - PKCE Public client authentication with Microsoft Entra AADSTS900144:

Image
Ran into this error "The request body must contain the following parameter: 'client_id'" here when trying to configure Microsoft Entra public client.  To resolve this issue, please ensure you set "Client authentication" to "send client credential in body".

microsoft entra - creating client credential client

Image
 To create a client credential login with microsoft, we can goto Microsoft Entra -> App Registration and create new app registration. Provide a name to your client for example "my-client-credential-registration" and click register. Configure your client API permission Goto API Permission (not Expose an API) and then  1. Grant admin consent for default directory 2. Add Microsoft Graph permission and select Application permission. It is stated there that this is for application running as background task.  Then select "User.Read.All" permission. You should have the following configuration. This settings here is what define your JWT scope. In this configuration, you will get a "User.Read.All" - if you requested "https://graph.microsoft.com/.default" as your request scope. Please remember to Grant Admin consent permission otherwise the scope or permission you specify will not appear. 3. Next create a secret for your client. So we go to "Certi...

opencode plugin with skills setup - continuation of this blog https://mitzen.blogspot.com/2026/04/opencode-creating-plugin-and.html

Image
In the previous post , we learned how to setup plugin so we can call it from opencode. In this post, we are going to add a skill - bragging skills - as I find it really important arsenal to have especially in an interview.  So we only need to update our config object for opencode. Let's see an example of how to do it with skills   config : async ( config : any ) => {       config . skills = config . skills || {};       config . skills . paths = config . skills . paths || [] ;       if ( ! config . skills . paths . includes ( skillsDir )) {         config . skills . paths . push ( skillsDir ) ;       } And that's it. Once you have restart opencode, it will load my new skills.  The full code is here and the repo here: https://github.com/kepungnzai/appcoreopc-num-mastery.git import { type Plugin } from " @opencode-ai/plugin " import { tool } from " @opencode-ai/pl...

azure speech to text using azure AI foundry

Image
In this example, we will try to test out Azure speech to text by. First we need to create an Azure foundry project. Go to Azure portal then on the left, select   "Use with Foundry" and create a foundry resource.] After you created it, it will look something like this. After it is completed, click on the link to goto Azure foundry, then select Build -> Model -> Azure Speech speech to text.  And you will get some endpoints and keys that you can use. Or if you're not doing any coding, then you can just upload a file or click on "Start recording" for a demo.  The beauty of it is, you can see it working in real-time Then it can return JSON as an output. And finally you can use code to interact with it  Example of pre-generated c# code look like this. using Microsoft . CognitiveServices . Speech ; using Microsoft . CognitiveServices . Speech . Audio ; class Program {     static async Task Main ( string [] args )     {     ...

terraform import existing resources - not quite with 1.5.x with generated output

Image
Terraform import can be quite interesting thing to do. So let's start with us trying to import a storage account. So we will start off using hcl import statement to import this.  provider "azurerm" {   features {} } resource "azurerm_storage_account" "imported_storage" {   name                     = " saforimort "   resource_group_name       = " mytest-kv-rg "   location                 = " australiaeast "   account_tier             = " Standard "   account_replication_type = " LRS " } import {   to = azurerm_storage_account . imported_storage   id = " /subscriptions/your-subscription-id/resourceGroups/ mytest-kv-rg/providers/Microsoft.Storage/storageAccounts/saforimort " } As you can see here, we are trying to import to  "azurerm_storage_account" "imported_storage" . and we just ne...

opencode - creating plugin and distributing it via npm

Image
We can easily create a plugin for opencode. In this example, we are just going to write a simple output. First we need to create a nodejs project using the following code. Please refer to this code repo here for typescript setup and other codes.  https://github.com/kepungnzai/appcoreopc-num-mastery. In this code, the most important thing is it must inherit from Plugin (quite important) otherwise your agent might not be able to figur out. import { type Plugin } from " @opencode-ai/plugin " import { tool } from " @opencode-ai/plugin/tool " export const AppcoreopcNumMastery : Plugin = async () => {   const myTool = tool ( {     description : " A simple plugin. " ,     args : {       query : tool . schema . string () . describe ( " Question or topic to submit to Google AI Mode " ) ,       timeout : tool . schema . number () . min ( 5 ) . max ( 120 ) . optional () . describe ( " Timeout in seconds (...