This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import requests | |
| import json | |
| def main(): | |
| client_id = "<CLIENT ID>" | |
| client_secret = "<CLIENT SECRET>" | |
| resource_id = "https://graph.microsoft.com" | |
| tenant = "<TENANT NAME OR GUID> (like microsoft.com or jpd.ms)" | |
| graph_query = "<GRAPH PATH> - example: users/john@jpd.ms" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import azure.functions as func | |
| from azure.keyvault import KeyVaultClient, KeyVaultAuthentication | |
| from azure.common.credentials import ServicePrincipalCredentials | |
| # see https://docs.microsoft.com/en-us/python/api/overview/azure/key-vault?view=azure-python | |
| def auth_callback(server, resource, scope): | |
| credentials = ServicePrincipalCredentials( | |
| client_id = '<CLIENT ID>', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| // once you create a computer vision service in Azure, you'll get the region and service key | |
| // CV OCR docs are here: https://eastus2.dev.cognitive.microsoft.com/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fc | |
| var recognizer = new Recognizer("<REGION OF YOUR CV SERVICE>", "<CV SERVICE KEY>"); | |
| // here's an example if the image to OCR is on the internet somewhere already | |
| recognizer.RecognizeFromImageUrl("<URL TO IMAGE, IF AVAILABLE ON INTERNET>", "ar").Wait(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Contact | |
| { | |
| [JsonProperty("name")] | |
| public string Name { get; set; } | |
| [JsonProperty("email")] | |
| public string Email { get; set; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Project Sdk="Microsoft.NET.Sdk"> | |
| <PropertyGroup> | |
| <TargetFramework>netstandard2.0</TargetFramework> | |
| </PropertyGroup> | |
| <ItemGroup> | |
| <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" /> | |
| <PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="3.19.8" /> | |
| </ItemGroup> | |
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # you may not need tenantId, but if it is ambiguous you should set it here | |
| Connect-AzureAd -TenantId | |
| # name of your MSI service principal, in my case msi-func. You can also get the ID from Enterprise Applications in AAD (not App Reg) | |
| $msifunc = Get-AzureADServicePrincipal -SearchString "msi-func" | |
| # name of your AAD service principal, in my case aad-func. You can also get the ID from App Registrations in AAD | |
| $aadapp = Get-AzureADServicePrincipal -SearchString "aad-func" | |
| # Id - the ID of the role. You can get it from the app's manifest | |
| # PrincipalId - the object ID of the MSI principal | |
| # ObjectId - the object ID of the MSI principal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "frameworks":{ | |
| "net46": { | |
| "dependencies": { | |
| "Microsoft.Azure.Services.AppAuthentication": "1.1.0-preview" | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Net; | |
| using System.Net.Http; | |
| using System.Net.Http.Headers; | |
| using Microsoft.Azure.Services.AppAuthentication; | |
| public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) | |
| { | |
| var target = "<target app client ID>"; | |
| var azureServiceTokenProvider = new AzureServiceTokenProvider(); | |
| string accessToken = await azureServiceTokenProvider.GetAccessTokenAsync(target); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Net; | |
| using System.Security.Claims; | |
| public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) | |
| { | |
| var stuff = System.Security.Claims.ClaimsPrincipal.Current.Claims.Select(x => new { x.Type, x.Value }); | |
| return req.CreateResponse(HttpStatusCode.OK, stuff); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| param( | |
| [string]$InstallDir = "drive:\path\to\folder\chrome-win32", | |
| [switch]$Verbose = $false | |
| ) | |
| $rootDir = $InstallDir | |
| $latest = Invoke-WebRequest -Uri "https://www.googleapis.com/storage/v1/b/chromium-browser-snapshots/o/Win_x64%2FLAST_CHANGE" -Verbose:$Verbose | |
| $data = ConvertFrom-Json -InputObject $latest.Content | |
| $build = $data.metadata.'cr-commit-position-number' | |
| Write-Host Latest is $build, looking for your version... |