Skip to content

Instantly share code, notes, and snippets.

View jlucaspains's full-sized avatar

Lucas Pains jlucaspains

View GitHub Profile
@jlucaspains
jlucaspains / CreateAppRegs.ps1
Last active April 7, 2024 21:06
Create app registrations and add roles bound to azure entra groups
[CmdletBinding()] param ()
$AppNames = @(
"OrdersApi",
"PeopleApi"
)
$Envs = @(
"dev",
"qa"
)
@jlucaspains
jlucaspains / app-gateway-identity.bicep
Last active April 25, 2024 14:40
Bicep to deploy application gateway and its required components for an externally visible Web App
@description('App Service location. Default is the location of the resource group.')
param location string = resourceGroup().location
@description('App base name')
param appBaseName string = 'myapp'
@description('Environment Name.')
param envName string = 'dev'
var applicationGateWayName = 'apgw-${appBaseName}-${envName}-${location}-001'
@jlucaspains
jlucaspains / CopyCertBetweenKeyVaults.ps1
Created November 23, 2022 22:31
Copy a certificate from one Azure key vault to another
$CertName = 'mycert'
$SrcVault = 'kv-cert-issuer-001'
$DstVault = 'kv-cert-consumer-001'
$secret = Get-AzKeyVaultSecret -VaultName $SrcVault -Name $CertName
$secretValueText = '';
$ssPtr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($secret.SecretValue)
try {
$secretValueText = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($ssPtr)
}
finally {
<script setup lang="ts">
import { ref, watch, onMounted } from "vue";
const props = defineProps<{
modelValue: number;
}>();
const emit = defineEmits<{
(e: "update:modelValue", value: number): void;
}>();
- task: joachimdalen.pull-request-utils.5c6ec8a1-d04c-44c0-99b8-42dd865b42e8.PullRequestComments@0
displayName: 'Pull Request Comments'
inputs:
action: createOrUpdate
content: |
Environment created at https://$(siteName).lpains.com
To access it, you need to update your hosts file. Using a powershell terminal as admin, run the following:
```powershell
variables:
prId: "$(System.PullRequest.PullRequestId)"
prName: "PR$(prId)"
siteName: '$(prName)'
dbServer: 'LPainsDB'
dbName: '$(siteName)'
ConnectionString: 'server=$(dbServer);database=$(dbName);integrated security=sspi;'
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"Default": "Data Source=MyDB;Initial Catalog=DbName;Integrated Security=True;"
}
# remember to run this script as an Admin
Import-Module SQLServer
# get open PRs from your repository
$B64Pat = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("your pat token goes here"))
$header = @{Authorization = "Basic $B64Pat"}
$url = "https://dev.azure.com/your-org/your-project/_apis/git/pullrequests?repositoryId=d26dc76c-6593-4612-acde-4ac37af9cf2f&includeCommits=false&includeWorkItemRefs=false"
$prArray = (Invoke-RestMethod -Uri $url -Method Get -ContentType "application/json" -Headers $header).value
# find the existing environments in the VM
$guid = [guid]::NewGuid().ToString("B")
netsh http add sslcert hostnameport="$siteName.lpains.com:443" certhash=thumbprint certstorename=MY appid="$guid"
appcmd add apppool /in < c:\apppools.xml
appcmd add site /in < c:\sites.xml