Skip to content

Instantly share code, notes, and snippets.

{
"administratorsGroup": null,
"authorization": {
"scheme": "ServicePrincipal",
"parameters": {
"serviceprincipalid": "##ServicePrincipalId##",
"authenticationType": "spnKey",
"serviceprincipalkey": "##ServicePrincipalKey##",
"tenantid": "##TenantId##"
}
{"lastUpload":"2021-01-29T13:57:27.583Z","extensionVersion":"v3.4.3"}
#Give access
az rest --method post --uri 'https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2015-07-01'
#Remove access
$account = username@example.com
az role assignment delete --assignee $account --role 'User Access Administrator' --scope '/'
$PersonalAccessToken = '<Put your PAT Token>'
$TeamProject = '<Project Name>'
$TeamFoundationCollectionUri = 'https://dev.azure.com/<OrganizationName >'
$AppRegistrationName = '<Service Principal Name>'
$AppPassword = '<Service Principal Secret>'
$AppSecurePassword = ConvertTo-SecureString -String:$AppPassword -AsPlainText -Force
.\Install-ServiceConnectionSubscription.ps1 -PersonalAccessToken $PersonalAccessToken `
-TeamFoundationCollectionUri:$TeamFoundationCollectionUri `
-TeamProject:$TeamProject `
<#
.SYNOPSIS
Creates a service connection for a subscription
Please ensure you are already logged to azure using az login
#>
param(
# Azure DevOps Personal Access Token (PAT) for the 'https://dev.azure.com/[ORG]' Azure DevOps tenancy
[Parameter(Mandatory)]
[string]
$PersonalAccessToken,
az login
$tenantName = "contso"
# Defaults to UK South
.\Install-AzureEnvironment.ps1 -Environment $tenantName -Name "SharePointMSAL"
# If wish to change location
#.\Install-AzureEnvironment.ps1 -Environment $tenantName -Name "SharePointMSAL" -Location:'<Location>'
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
using System;
using CSharpLibrary;
namespace CSharpConsole
{
class Program
{
static void Main(string[] args)
{
LibraryProject();
using System;
namespace CSharpLibrary
{
public static class IntLibrary
{
public static bool NumberGreaterThan5(this string value)
{
Int32 intValue = 0;
bool canConvert = Int32.TryParse(value, out intValue);
{
"environment": "<tenantName>",
"name": "SharePointMSAL",
"site": "<relative URL e.g, /sites/teamsite>"
}