20191221

Azure Terraform Role Definition

For security purpose, we tend to create service principal that can performs Terraform operations only within a specific resource group without able modify resource outside the resource group within the same subscription.

Reality is we still need to allow the service principal to run few actions within the scope of the subscription.

Therefore here is the role definition with actions required that Terraform operations need to execute successfully.

{
    "Name": "Terraform",
    "Description": "Role definition has actions required that Terraform operations need",
    "Actions": [
        "*/read",
        "Microsoft.Sql/register/action",
        "Microsoft.CognitiveServices/register/action",
        "microsoft.insights/register/action"
    ],
    "AssignableScopes": ["/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]
}

With this as json content, we may run the following command to create the role and assign it to the subscription.

az role definition create --role-definition terraform-role-definition.json


Reference

Schedule Dark Mode













To schedule dark mode at 7 PM:

schtasks /CREATE /SC DAILY /TN "Enable Dark Mode" /TR "C:\Windows\System32\reg.exe add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize /v AppsUseLightTheme /t REG_DWORD /d 0 /f" /ST 19:00

To schedule light mode at 7 AM:

schtasks /CREATE /SC DAILY /TN "Disable Dark Mode" /TR "C:\Windows\System32\reg.exe add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize /v AppsUseLightTheme /t REG_DWORD /d 1 /f" /ST 7:00

Execute these commands in Command Prompt or PowerShell. There are additional steps you need to do to ensure it is enabled even if you turn on your laptop after the scheduled time.

  1. Launch Task Scheduler.
  2. Open the Properties dialog of the tasks we created.
  3. Go to Settings and check the box "Run task as soon as possible after a scheduled start is missed."


Reference

  1. How to Auto-Toggle Windows 10 Dark Mode at Night
  2. Schtasks.exe /Create

20191213

Generate self-signed certificate

openssl genrsa -out www.example.com.key 2048
openssl req -new -x509 -key www.example.com.key -out www.example.com.cert -days 3650 -subj /CN=www.example.com