Skip to content

Instantly share code, notes, and snippets.

View fabiocannas's full-sized avatar
🏠
Working from home

Fabio Cannas fabiocannas

🏠
Working from home
View GitHub Profile
@fabiocannas
fabiocannas / Android_Mobile_App_development_Export_PrivateKey_from_jks_file.txt
Created March 19, 2025 16:54
Android Mobile App development - Export Private Key from .jks file
Export the Private Key: First, you need to convert the JKS keystore to a PKCS12 format:
  keytool -importkeystore -srckeystore [keystore_path] -destkeystore [output_file.p12] -deststoretype PKCS12 -srcstorepass [password] -deststorepass [password]
@fabiocannas
fabiocannas / gist:9992f529a8c50d28e7dfdb53347dc470
Last active January 15, 2025 15:36
Cancel Azure SQL db import/export job
az login --tenant <tenant-id>
az sql db op list --resource-group my-rg --server mssql-srv --database mydb
az sql db op cancel --resource-group my-rg --server mssql-srv --database mydb --name <job-name(guid)>
@fabiocannas
fabiocannas / AZ_Update_Manager_patch_installation_results.kql
Last active December 10, 2024 09:34
Azure Resource Graph - KQL query for Azure Update Manager patch installation results
arg('').patchinstallationresources
| where type in ("microsoft.compute/virtualmachines/patchinstallationresults", "microsoft.hybridcompute/machines/patchinstallationresults")
| where properties.status == "Failed" or properties.status == "CompletedWithWarnings"
| where properties.lastModifiedDateTime > ago(1d)
| parse id with vmResourceId "/patchInstallationResults" *
| project vmResourceId
| distinct vmResourceId
@fabiocannas
fabiocannas / ARG_AZ_RSV_backup_jobs_failures.kql
Created December 9, 2024 15:59
Azure Resource Graph - check for Azure Recovery Services Vault backup jobs failures using kql query
arg('').RecoveryServicesResources
| where type in~ ('microsoft.recoveryservices/vaults/backupjobs')
| extend vaultName = case(type =~ 'microsoft.dataprotection/backupVaults/backupJobs', properties.vaultName, type =~ 'Microsoft.RecoveryServices/vaults/backupJobs', split(split(id, '/Microsoft.RecoveryServices/vaults/')[1], '/')[0], '--')
| extend friendlyName = case(type =~ 'microsoft.dataprotection/backupVaults/backupJobs', strcat(properties.dataSourceSetName, '/', properties.dataSourceName), type =~ 'Microsoft.RecoveryServices/vaults/backupJobs', properties.entityFriendlyName, '--')
| extend dataSourceType = case(type =~ 'Microsoft.RecoveryServices/vaults/backupJobs', properties.backupManagementType, type =~ 'microsoft.dataprotection/backupVaults/backupJobs', properties.dataSourceType, '--')
| extend protectedItemName = split(split(properties.backupInstanceId, 'protectedItems')[1], '/')[1]
| extend vaultId = tostring(split(id, '/backupJobs')[0])
| extend vaultSub = tostring(split(id, '/')[2])
|
@fabiocannas
fabiocannas / AZKVAuditLogs_CheckForSecretExpiry.kql
Created December 9, 2024 15:48
AZ KV Audit Logs - Check for secret expiry
AzureDiagnostics
| where OperationName contains "SecretNearExpiry" or OperationName contains "SecretExpired"
//| project SecretName = column_ifexists("eventGridEventProperties_data_ObjectName_s", "eventGridEventProperties_data_ObjectName_s")
@fabiocannas
fabiocannas / AGW_KV_SSLCert.ps1
Last active December 9, 2024 15:38
Azure Application Gateway - Create SSL certificate with Azure Key vault secret reference using Azure Application Gateway's user assigned managed identity
az login --tenant <tenant-id>
az keyvault set-policy --name <kv-name> -g <resource-group-name> --object-id <user-assigned-managed-identity-object-id> --certificate-permissions get list
az network application-gateway ssl-cert create -g <resource-group-name> --gateway-name <agw-name> -n <ssl-cert-name> --key-vault-secret-id <kv-secret-id>
@fabiocannas
fabiocannas / gist:d0311777f5d7edf93ff80d22454c21f5
Created December 9, 2024 15:16
How to Change the Password of a pfx File
openssl pkcs12 -in C:\Temp\SelfSigned1.pfx -out C:\Temp\SelfSigned2.pem -nodes
openssl pkcs12 -export -out C:\Temp\SelfSigned2.pfx -in C:\Temp\SelfSigned2.pem
@fabiocannas
fabiocannas / Debug_Azure_Function_App_event_grid_trigger_using_NGROK.txt
Created November 26, 2024 17:33
Debug Azure Function App event grid trigger using ngrok
Install ngrok via Chocolatey with the following command: choco install ngrok
ngrok config add-authtoken <auth_token>
ngrok http http://localhost:7071 --host-header="localhost:7071"
In Event Grid System Topic, create an event subscription of type web hook:
https://<random_identifier>.ngrok-free.app/runtime/webhooks/EventGrid?functionName=<function_name>
Set filter to event types
@fabiocannas
fabiocannas / GetAllResourcesInAzureSubscription.ps1
Created October 11, 2024 16:00
Get a list of all resources in an Azure Subscription using Powershell
Get-AzResource | Select-Object * | Export-Csv -Path "C:path\to\AzureSubscriptionResources.csv" -NoTypeInformation
@fabiocannas
fabiocannas / GenerateSSLCertLetsEncrypt.ps1
Created October 10, 2024 16:40
Get certificate from Let's Encrypt
Set-ExecutionPolicy RemoteSigned
Install-Module -Name Posh-ACME
$contactMail="<contact_mail>"
$domain="<domain>"
$password="<password>"
Set-PAServer LE_PROD
New-PACertificate $domain -AcceptTOS -Contact $contactMail -DnsPlugin AcmeDns -PluginArgs @{ACMEServer='auth.acme-dns.io'} -PfxPass $password