Tag Archives: Azure

Azure Application Insights customEvents and .NET 6

Getting customEvents with Azure Application Insights customEvents and .NET 6

dotnet new mvc -o videowebapp
cd videowebapp
dotnet add package Microsoft.ApplicationInsights.AspNetCore

Program.cs: Adding builder.Services.AddApplicationInsightsTelemetry();

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
IServiceCollection serviceCollection = builder.Services.AddApplicationInsightsTelemetry();
builder.Services.AddControllersWithViews();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();

Getting InstrumentationKey

az resource show \
    --resource-group <resource_group_name> \
    --name <resource_name> \
    --resource-type "Microsoft.Insights/components" \
    --query properties.InstrumentationKey

appsettings.json : adding InstrumentationKey

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "ApplicationInsights": {
    "InstrumentationKey": "0000000000000000000000000000000",
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Error"
    }
  }
}

HomeController.cs : Adding ” this.aiClient.TrackEvent(“CommentSubmitted”); ”

using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using videowebapp.Models;
using Microsoft.ApplicationInsights;

namespace videowebapp.Controllers;

public class HomeController : Controller
{
    private TelemetryClient aiClient;
 //   private readonly ILogger<HomeController> _logger;

public HomeController(TelemetryClient aiClient)
{
    this.aiClient = aiClient;
}
/*    public HomeController(ILogger<HomeController> logger)
    {
        _logger = logger;
    }
*/
    public IActionResult Index()
    {
       // _logger.LogWarning("fujuTE: An example of a Warning trace..");
       // _logger.LogError("fujuTE: An example of an Error level message");
        return View();
    }

    public IActionResult Privacy()
    { 
        // _logger.LogInformation("fujuTE: An example of a Information trace..");
        // Track an event
        this.aiClient.TrackEvent("CommentSubmitted");

        // Track an event with properties
        this.aiClient.TrackEvent("VideoUploaded", new Dictionary<string, string> {{"Category", "Sports"}, {"Format", "mp4"}});

        return View();
    }

    [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
    public IActionResult Error()
    {
        return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
    }
}
Application Insight – Transaction Search
Getting customEvents vai Log Analytics Workspace

See Also:

Terraform: Create Virtual Network Peering and VMs

Sample “Virtual network peering” with 2 VMs with terraform deployment

TF file: https://github.com/fujute/m18h/tree/master/tf/virtual-network-peering

  • main.tf
  • variables.tf

Building VNET peering with terraform

terraform plan -out main-vnet.tfplan
terraform apply "main-vnet.tfplan"

Sample screenshot to access fx1-vm1 in fx1-network1 via jump host fx1-vm2

ssh azureuser@10.0.2.4

adminuser@fx1-vm2:~$ hostname
fx1-vm2
adminuser@fx1-vm2:~$ ssh azureuser@10.0.2.4
azureuser@10.0.2.4's password:
Welcome to Ubuntu 18.04.6 LTS (GNU/Linux 5.4.0-1080-azure x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Thu Jun  2 10:38:38 UTC 2022

  System load:  0.33              Processes:           131
  Usage of /:   6.5% of 28.90GB   Users logged in:     0
  Memory usage: 3%                IP address for eth0: 10.0.2.4
  Swap usage:   0%


0 updates can be applied immediately.

New release '20.04.4 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Thu Jun  2 10:37:25 2022 from 192.168.2.4
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

azureuser@fx1-vm1:~$

delete the deployment with terraform destroy

terraform plan -destroy -out main-vnet.destroy.tfplan
terraform apply main-vnet.destroy.tfplan

Optional Tasks:

  • Adding Private Endpoint for Azure Blob Storage and Private DNS Zone

Reference command:

az vm image list-skus --location eastasia --offer WindowsServer --publisher MicrosoftWindowsServer
az vm image list-skus --location eastasia --offer UbuntuServer --publisher Canonical
az vm list-skus -l southeastasia  --resource-type virtualMachines  --output table | grep Standard_D2ds_v4

az account set --subscription "xxxxxxxxxxxxxxx"
az vm list-usage --location southeastasia -o table | grep -E -w -i  'DSv4|FSv2|ESv4'
#!/bin/bash
declare -a subscrptionsID=(
"12345-12342134-12342134-1234"
"12345-12342134-12342134-1235"
"12345-12342134-12342134-1236"
"12345-12342134-12342134-1237"
)

echo "${subscrptionsID[@]}"

for mySubscrptionsID in "${subscrptionsID[@]}" 
do
   az account set --subscription  “$mySubscrptionsID”
   az vm list-usage --location southeastasia -o table | grep -E -w -i  'DSv4|FSv2|ESv4|DSv3'
done

Configuring self-hosted runners with a default self-signed certificate for GitHub Enterprise Server

Quick fix:

  1. Copy “/etc/haproxy/ssl.crt” from GHE Server to Runner machine under ” /usr/local/share/ca-certificates/ “
  1. Updated the certificate in the runner server by running ” sudo update-ca-certificates “
$ az vm image list --all -f GitHub-Enterprise | grep '"urn":' | sort -V
#Standard E4s v3 (4 vcpus, 32 GiB memory)
$ az vm create -n myghesvr -g My-01-RG --size Standard_E4ds_v4 -l southeastasia --image GitHub:GitHub-Enterprise:GitHub-Enterprise:3.3.3 --storage-sku StandardSSD_LRS
$ az vm disk attach --name ghevm-data-01 --new --resource-group My-01-RG --size-gb 100 --sku Standard_LRS --vm-name myghesvr  
$ az vm open-port -n myghesvr  -g My-01-RG --port 8443
$ az vm open-port -n myghesvr -g My-01-RG --port 122 --priority 903
$ az vm open-port -n myghesvr -g My-01-RG --port 443 --priority 904
$ az vm open-port -n myghesvr -g My-01-RG --port 80 --priority 905


Screenshot: Local machine:

$ scp -P 122 admin@myghesvr.exzilla.com:/etc/haproxy/ssl.crt .
$ scp ssl.crt azuser@gherne4.exzilla.com:/home/azuser/ghe7-ssl.crt

Screenshot: Runner machine:

azuser@myghesvr:~$ openssl x509 -noout -text -in /etc/haproxy/ssl.crt
azuser@gherne4:~$ sudo cp ghe7-ssl.crt /usr/local/share/ca-certificates/
azuser@gherne4:~$ ls -l /usr/local/share/ca-certificates
total 4
-rw-r--r-- 1 root root 1618 Feb 13 09:35 ghe7-ssl.crt
azuser@gherne4:~$ sudo update-ca-certificates
Updating certificates in /etc/ssl/certs…
1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d…
done.
azuser@gherne4:~$

Sample YAML file: m18h/sample-actions-ghe7-self-signed.yaml at master · fujute/m18h (github.com)

Alternative: Disabling TLS certificate verification

## https://docs.github.com/en/actions/hosting-your-own-runners/monitoring-and-troubleshooting-self-hosted-runners#disabling-tls-certificate-verification
##
export GITHUB_ACTIONS_RUNNER_TLS_NO_VERIFY=1
./config.sh --url https://github.com/octo-org/octo-repo --token
./run.sh

See Also:

* Troubleshooting GitHub Actions for your enterprise – GitHub Docs
* https://github.com/actions/runner/issues
* Monitoring and troubleshooting self-hosted runners
* Troubleshooting GitHub Actions for your enterprise

ข้อมูลประกอบการบรรยายจาก WUNCA33– Microsoft Azure IoT Services

ข้อมูลจาการบรรยาย “ Bringing the Internet of Things to life with Microsoft Azure IoT Services “  – 14-July-2016

Slidehttps://1drv.ms/b/s!AgZyyCR4CCEsh4AJZ6Uzje5Ew3OpBg

https://youtu.be/L8xjSjxaaVA
Case study  จาก ThyssenKrupp Elevators

* https://www.microsoft.com/en-gb/server-cloud/customer-stories/thyssen-krupp-elevator.aspx

Continue reading ข้อมูลประกอบการบรรยายจาก WUNCA33– Microsoft Azure IoT Services

IT INNOVATION SERIES: What’s New in Hybrid IT Infrastructure| 26-Apr-2016

IT INNOVATION SERIES “What’s New in Hybrid IT Infrastructure: Increasing efficiency and scalability with Windows Server 2016 and Microsoft Azure” ( Microsoft IT Camps)   in Bangkok , Tuesday 26-Apr-2016 from 9:00 am to 5:00 pm.

This 26-April-2016 – IT INNOVATION SERIES ( IT Camps )  already fully booked .
ขณะนี้ ที่นั่งที่เตรียมไว้เต็มแล้วครับ – ผมขอขอบคุณทุกท่านที่ให้ความสนใจใน technical workshop ครั้งนี้ครับ

IT INNOVATION SERIES: What’s New in Hybrid IT Infrastructure| 26-Apr-2016

สำหรับ Technical training ครั้งนี้ผมอนุญาตเฉพาะท่านที่ได้ลงทะเบีบนผ่านระบบเท่านั้นนะครับ

สำหรับรอบเดือนเมษายนนี้ผมขอนำเสนอในหัวข้อ “What’s New in Hybrid IT Infrastructure”  โดยท่านที่เข้าร่วม technical training ครั้งนี้จะได้เรียนรู้ความสามารถใหม่ ๆ ของ Windows  Server 2016 และ MMicrosoft Azure ในมุมมองการประยุกต์ใช้ด้าน IT Infrastructure ในรูปแบบ Hybrid Cloud โดยคาดหวังไว้ว่าท่านที่มาร่วมกิจกรรมจะได้กลับไปพร้อมกับสิ่งเหลานี้ครับ

  • ท่านจะได้ศึกษาและทำความเข้าใจความสามารถใหม่เรื่อง Hyper-V ของ   Windows  Server 2016 และการทำงานร่วมกันกับ Microsoft Azure 
  • ท่านจะได้ศึกษาและความเข้าใจการนำ Software-defied Storage และ Network  ที่ครอบคลุมเรื่ิอง  performance, flexibility และ redundancy ของ Windows Server 2016
  • ท่านจะได้ศึกษาและทำความเข้าใจเรื่องการใข้งาน NanoServer  และ Container
  • ท่านจะได้ศึกษาและทำความเข้าใจเรื่อง Virtual Network เพื่อให้ทำงานร่วมกันได้ระหว่าง on-premises infrastructure และ Microsoft Azure
  • ท่านจะได้ทดลองการใช้งาน Azure Resource Manager เพื่อช่วยในการ Deploy ระะบบทีมีความซับซ้อน

Continue reading IT INNOVATION SERIES: What’s New in Hybrid IT Infrastructure| 26-Apr-2016

Azure Community Meeting in Bangkok #1 | 26-Dec-2015

Azure Community Meeting in Bangkok #1 | 26-Dec-2015
งานนี้ Azure Thailand User Group & Narisa.com ขอจัดขึ้นเล็ก ๆ เพื่อให้เพื่อนที่สนใจใน Technical และเรื่องกระบวนการจัดการบริหาร Microsoft Azure โดยครอบคลุมเรื่อง Extending  Datacenter , DevOps และ IoT ได้มีเวลามาคุยกันก่อนสิ้นปีเรื่องความรู้ และกิจกรรมที่เกี่ยวข้อง งานนี้เลยขอนำแสนอเป็นรูปแบบบรรายากาศสนุก กันเอง ก่อนหยุด ปีใหม่ ครับ

Continue reading Azure Community Meeting in Bangkok #1 | 26-Dec-2015

ขั้นตอนการลงทะเบียน Microsoft Azure for DreamSpark ด้วย Verification Code

แนะนำขั้นตอนการลงทะเบียนเพื่อใช้บริการ Microsoft Azure สำหรับนักศึกษา โดยผ่านโครงการ Microsoft Azure for DreamSpark  ด้วยวิธีการ verification โดยใช้  Verification Code

โดยที่โครงการนี้เป็นการสนับสนุนให้นักศึกษาได้มีโอกาสทดลองพัฒนา และ publish ผลงานที่เป็น web apps ของตนเองไปบน Microsoft Azure โดยไม่ต้องเสียค่าใช้จ่าย และไม่จำเป็นต้องใช้บัตรเครดิต ซึ่งนักศึกษาสามารถใช้ปรโยชน์จากบริการดังต่อไปน้
•Web Apps
•MySQL DB
•VSO
•Application Insights

การเข้าใช้งาาน Microsoft Azure for Students นั้นจะประกอบด้วย 2 ขั้นตอนใหญ่ ๆ คือ
1. การยืนยันความเป็นนักศึกษา ซึ่งจะมีวิธีในการยืนยันได้หลายวิธีเช่น ยืนยันด้วย email  หรือ ยืนยันด้วย  Vverification code เป็นต้น
2.การลงทะเบียนเขัาใช้งาน Microsoft Azure for Students

เนื้่อหาใน Blog Entry นี้จะเป็นการอธิบายเฉพาะในส่วนการ ยืนยันความเป็นนักศึกษาด้วย Verification Code เท่านั้นครับ  ( หากท่านต้องการ verify โดยใช้ email นักศึกษากรุณาดูรายละเอียดที่นี่ ครับ )

image_thumb3

การเตรียม Verification Code

Continue reading ขั้นตอนการลงทะเบียน Microsoft Azure for DreamSpark ด้วย Verification Code

การใช้งาน Microsoft Azure Virtual Machines สำหรับผู้เริ่มต้น

ในบทเรียนเรื่อง  “  การใช้งาน Microsoft Azure Virtual Machines สำหรับผู้เริ่มต้น ” นี้ (ซึ่งเป็นบทเรียนที่ 9 ใน series  ของ MVA ภาคภาษาไทย)  ได้นำเสนอโดยคุณพงศ์ภูมิพันธ์ เตี๋ยอนุกูล ซึ่งมีเนื้อหาที่เหมาะสำหรับท่านที่เริ่มต้นศึกษา หรือกำลังหาแนวทางการใช้ประโยชน์จาก Microsoft Azure Virtual Machines  เพื่อการขยายหรือต่อยอดจากระบบที่ใช้งานในปัจจุุบัน

ท่านสามารถเรียนได้ ฟรี พร้อมทั้ง download เนื้อหา ( video การสอน และ powerpoint )ได้ที่ http://www.microsoftvirtualacademy.com/training-courses/microsoft-azure-virtual-machines-thai

Microsoft Azure Virtual Machines สำหรับผู้เริ่มต้น

Instructor | Phongphumphan Tia-Anukul | พงศ์ภูมิพันธ์ เตี๋ยอนุกูล | Computer Technical Specialist, Consultant and Special instructor

บทเรียนนี้อธิบายถึงภาพรวมของ Microsoft Azure VM แนะนำการสร้าง VM รวมทั้งกล่าวถึงภาพรวมของ Microsoft Azure Storage การเพิ่มความสามารถของ Disk IO ด้วย Storage Space และการ Migrating Virtual Machine to Microsoft Azure โดยได้มีการแบ่งเนื้อหาเป็น 4 ส่วนดังนี้

  • อธิบายหลักการของ Microsoft Azure VM การสร้าง VM จาก Gallery และการ Capture VM Image
  • อธิบายถึงภาพรวมของ Microsoft Azure Storage Blob service การเพิ่ม Data Disk ให้กับ VM ร่วมถึงการ Upload VHD เพื่อใช้งานร่วมกับ VM
  • อธิบายถึงการเพิ่มความสามารถของ Disk IO ด้วย Storage Space
  • อธิบายถึงความยืดหยุ่น และ คล่องตัวของ VHD รวมถึงการย้าย Virtual Machines ที่เรามีอยู่ไปยัง Azure

See Also:
รายชื่อบทเรียนอื่น ๆ ที่เป็นภาษาไทยใน MVA สามารถดูได้จาก http://www.fuju.org/?cat=61  นะครับ

ขั้นตอนการลงทะเบียน Microsoft Azure for DreamSpark และยืนยันด้วย email นักศึกษา

แนะนำขั้นตอนการลงทะเบียนเพื่อใช้บริการ Microsoft Azure สำหรับนักศึกษา โดยผ่านโครงการ Microsoft Azure for DreamSpark  ด้วยวิธีการ verification โดยใช้ email ของนักศึกษา ( email verification )

โดยที่โครงการนี้เป็นการสนับสนุนให้นักศึกษาได้มีโอกาสทดลองพัฒนา และ publish ผลงานที่เป็น web apps ของตนเองไปบน Microsoft Azure โดยไม่ต้องเสียค่าใช้จ่าย และไม่จำเป็นต้องใช้บัตรเครดิต ซึ่งนักศึกษาสามารถใช้ปรโยชน์จากบริการดังต่อไปน้
•Web Apps
•MySQL DB
•VSO
•Application Insights

การเข้าใช้งาาน Microsoft Azure for Students นั้นจะประกอบด้วย 2 ขั้นตอนใหญ่ ๆ คือ
1. การยืนยันความเป็นนักศึกษา ซึ่งจะมีวิธีในการยืนยันได้หลายวิธีเช่น ยืนยันด้วย email  หรือ ยืนยันด้วย  Vverification code เป็นต้น
2.การลงทะเบียนเขัาใช้งาน Microsoft Azure for DreamSpark

เนื้่อหาใน Blog Entry นี้จะเป็นการอธิบายเฉพาะในส่วนการ ยืนยันความเป็นนักศึกษาด้วย email ( email verification ) เท่านั้นครับ  ( หากท่านต้องการ verify ด้วย Verification Code กรุณาดูรายละเอียดที่นี่ ครับ )

image

โดยขั้นตอนจะเป็นดังนี้

Continue reading ขั้นตอนการลงทะเบียน Microsoft Azure for DreamSpark และยืนยันด้วย email นักศึกษา

Microsoft Azure Fundamentals: Websites [บรรยายไทย]

มาถึงลำดับที่ 2 ที่ได้มีการทำการบรรยายไทย  เรื่องที่ 2 นี้ผมขอนำเสนอเรื่องราวที่เกี่ยวกับ Cloud Computing โดยเลือกเรื่อง  Microsoft Azure Fundamentals: Websites มาแปล ซับ ( Sub Title )  ซึ่งก็ต่อเนื่องจาก มาจากวิชา Networking Fundamentals  ที่ได้รับการตอบรับอย่างดีในช่วงที่ผ่านมา

image

จากความสนใจ Microsoft Azure ที่มีเพิ่มขึ้นเรื่อย ๆ  และหนึ่งในลักษณะงาน หรือ workload ที่เราสามารถเริ่มต้นใช้งานกันง่าย ๆ สำหรับ Azure ก็คงหนีไม่พ้น Azure App Service Web Apps ( ชื่อเดิม Azure Websites ) ผมคิดว่าเรื่องนี้น่าจะเป็นเรื่องที่เป็นประโยชน์ให้กับท่านที่สนใจอีกเรื่อง

อีกทั้ง  ในวันที่ 13 มีนาคมที่ผ่านมา ทาง Microsoft ก็ได้มีการแนะนำ Azure for Students  ซึ่งเป็นโครงการที่ออกมาเพื่อสำหรับนักศึกษาได้มีโอกาสใช้ Azure App Service Web Apps สำหรับการสร้าง การdeploy  โดยได้ใช้ภาษาที่ตนถนัดอย่างเช่น ASP.NET, Java, PHP, Node.js  หรือ Python.

ท่านสามารถเรียนได้ ฟรี พร้อมทั้ง download เนื้อหา  video การสอน และ powerpoint ที่ใช้สำหรับการสอบได้ที่ http://www.microsoftvirtualacademy.com/training-courses/microsoft-azure-fundamentals-websites 

Continue reading Microsoft Azure Fundamentals: Websites [บรรยายไทย]