Skip to content

Instantly share code, notes, and snippets.

@adrianhall
adrianhall / graphql-policy.xml
Created June 1, 2022 16:20
An example Azure API Management policy for Synthetic GraphQL.
<policies>
<inbound>
<base />
<validate-graphql-request max-depth="3" />
</inbound>
<backend>
<set-graphql-resolver parent-type="Query" field="getAllTodoItems">
<http-data-source>
<http-request>
<set-method>GET</set-method>
@adrianhall
adrianhall / Program.cs
Created August 16, 2021 22:56
ASP.NET 6 CRUDL in 40 lines of code
using Microsoft.AspNetCore.Datasync;
using Microsoft.AspNetCore.Datasync.EFCore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<AppDbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
builder.Services.AddDatasyncControllers();
var app = builder.Build();
2020-03-25T11:21:10.221-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.2.0_x5.exe: [DEBUG] AzureRM Request:
2020-03-25T11:21:10.221-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.2.0_x5.exe: PUT /subscriptions/XXXXXXXX-0871-4889-9045-d554e72e0ef0/resourceGroups/smud-dev/providers/Microsoft.Web/sites/appwiflofbm?api-version=2019-08-01 HTTP/1.1
2020-03-25T11:21:10.221-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.2.0_x5.exe: Host: management.azure.com
2020-03-25T11:21:10.221-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.2.0_x5.exe: User-Agent: Go/go1.12.6 (amd64-windows) go-autorest/v13.3.0 Azure-SDK-For-Go/v38.1.0 web/2019-08-01 HashiCorp Terraform/0.12.24 (+https://www.terraform.io) Terraform Plugin SDK/1.6.0 terraform-provider-azurerm/2.2.0 pid-222c6c49-1b0a-5959-a213-6608f9eb88202020-03-25T11:21:10.221-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.2.0_x5.exe: Content-Length: 1413
2020-03-25T11:21:10.221-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.2.0_x5.exe: Content-Typ

What I'm trying to do

Write a python program (Python 3.8.2, Visual Studio Code insiders + insiders plugin, Windows 10) to upload a python file to a new storage blob, then set up distributed tracing and logging.

Starting application

This should be fairly basic.

  • pip install --pre azure.identity
version: 0.1
frontend:
phases:
preBuild:
commands:
- bundle install
build:
commands:
- if [ "${AWS_BRANCH}" = "master" ]; then bundle exec jekyll b --baseurl /; else bundle exec jekyll b --baseurl / --future; fi
artifacts:
#if($ctx.prev.result.ids.size() == 0)
#set($result = {})
$util.qr($result.put("totalCount", $ctx.prev.result.totalCount))
$util.qr($result.put("nextToken",$ctx.prev.result.nextToken))
$util.qr($result.put("items", $ctx.prev.result.ids))
#return($result)
#end
#set($keys = [])
#foreach($id in ${ctx.prev.result.ids})
## Raise a GraphQL field error in case of a datasource invocation error
#if($ctx.error)
$util.error($ctx.error.message, $ctx.error.type)
#end
#set($result = {})
$util.qr($result.put("totalCount", $ctx.prev.result.totalCount))
$util.qr($result.put("nextToken",$ctx.prev.result.nextToken))
$util.qr($result.put("items", $ctx.result.data.devRestaurantReviews))
$util.toJson($result)
#set($keys = [])
#foreach($id in ${ctx.prev.result.ids})
#set($key = {})
$util.qr($key.put("typeName", $util.dynamodb.toString("LOCATION")))
$util.qr($key.put("id", $util.dynamodb.toString($id)))
$util.qr($keys.add($key))
#end
{
"version": "2018-05-29",
import gql from 'graphql-tag';
import { graphql } from 'react-apollo';
import * as React from 'react';
import UserBlockComponent from '../components/UserBlock';
const query = gql`
query me {
me { id name }
}
`;
import gql from 'graphql-tag';
import AWSAppSyncClient, { AUTH_TYPE } from 'aws-appsync';
import aws_config from './aws-exports';
import App from './src/App';
const client = new AWSAppSyncClient({
url: aws_config.aws_appsync_graphqlEndpoint,
region: aws_config.aws_appsync_region,
auth: {
type: aws_config.aws_appsync_authenticationType,