Skip to content

Instantly share code, notes, and snippets.

View jlattimer's full-sized avatar

Jason Lattimer jlattimer

View GitHub Profile
@jlattimer
jlattimer / MSFlow_AIDependency.json
Created March 12, 2018 03:25
Application Insights Dependency body #blog
{
"data": {
"baseData": {
"application_Version": "9.0.0.2090",
"properties": {
"orgName": "test.crm.dynamics.com",
"source": "Microsoft Flow"
},
"severityLevel": null,
"ver": 2,
@jlattimer
jlattimer / MSFlow_AIMetric.json
Created March 12, 2018 03:10
Application Insights Metric body #blog
{
"data": {
"baseData": {
"application_Version": "9.0.0.2090",
"dependencies": null,
"exceptions": null,
"measurements": null,
"message": null,
"metrics": [
{
@jlattimer
jlattimer / MSFlow_AIEvent.json
Created March 12, 2018 03:05
Application Insights Event body #blog
{
"data": {
"baseData": {
"application_Version": "9.0.0.2090",
"dependencies": null,
"exceptions": null,
"measurements": {
"SomethingTrackableNumber": 100
},
"message": null,
@jlattimer
jlattimer / MSFlow_AITrace.json
Last active March 12, 2018 03:05
Application Insights Trace body #blog
{
"data": {
"baseData": {
"application_Version": "9.0.0.2090",
"dependencies": null,
"exceptions": null,
"measurements": null,
"message": "Hello world",
"metrics": null,
"properties": {
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracer = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
MethodTimeLogger.Tracer = tracer;
// What manually setting up method timing might look like
ManualTimer(tracer);
// What using IL weaving to inject logging looks like
string vaultName = "https://myvaulttest.vault.azure.net";
string secretName = "MyPassword";
//Retrieve the latest version of a secret by name
var getKeyByNameTask = Task.Run(async () => await GetSecretByName(token, vaultName, secretName));
Task.WaitAll(getKeyByNameTask);
if (getKeyByNameTask.Result == null)
throw new InvalidPluginExecutionException("Error retrieving secret versions from key vault");
var retrievedSecretUrl = getKeyByNameTask.Result;
// Retrieve a secret by its url
string secretUrl = "https://myvaulttest.vault.azure.net/secrets/MyPassword/00000000000000000000000000000000";
//Retrieve a secret by its url
var getKeyByUrlTask1 = Task.Run(async () => await GetSecretByUrl(token, secretUrl));
Task.WaitAll(getKeyByUrlTask1);
if (getKeyByUrlTask1.Result == null)
throw new InvalidPluginExecutionException("Error retrieving secret value from key vault");
//Deserialize the vault response to get the secret
GetSecretResponse getSecretResponse1 = DeserializeResponse<GetSecretResponse>(getKeyByUrlTask1.Result);
//returnedValue is the Azure Key Vault Secret
string clientId = "00000000-0000-0000-0000-000000000000";
string clientSecret = "00000000000000000000000000000000000000000000";
string tenantId = "00000000-0000-0000-0000-000000000000";
//Retrieve the access token required for authentication
var getTokenTask = Task.Run(async () => await GetToken(clientId, clientSecret, tenantId));
Task.WaitAll(getTokenTask);
if (getTokenTask.Result == null)
throw new InvalidPluginExecutionException("Error retrieving access token");
//Deserialize the token response to get the access token
@jlattimer
jlattimer / CrmAnnyangTabNavigation.js
Last active January 26, 2017 02:30
Use the annyang to navigate between tabs in Chrome
function TabNavigation() {
//Be sure to include annyang on the form
//https://cdnjs.cloudflare.com/ajax/libs/annyang/2.6.0/annyang.min.js
//https://github.com/TalAter/annyang
if (annyang) {
//'show me' is the beginning of the command
//anything said after that will be passed to the function where it's used
//to match the tab label to the spoken input to determine the focused tab
var command = {
"show me *name": function (name) {
function SetDocumentFrame() {
//You can see what the url should be by navigating to the 'Documents' area under related records, viewing the page soure
//and looking for 'areaSPDocuments'. The formid appears to be nothing more than a random guid value and not tied to anything
//specific in your org.
//Use: Make sure Document Management is enabled for the entity (helps to turn on automatic folder creation)
// Add a web resource with this code to the form
// Execute this function during the form's OnLoad event