Skip to content

Instantly share code, notes, and snippets.

Avatar
🖖
Merging without reviewing.

Gerade Geldenhuys GeradeDev

🖖
Merging without reviewing.
View GitHub Profile
View build-ci.yml
- task: RunARMTTKTests@1
inputs:
templatelocation: '$(System.DefaultWorkingDirectory)\*'
resultLocation: '$(System.DefaultWorkingDirectory)'
View conditional-deployment.json
{
"condition": "[equals(parameters('newOrExisting'),'new')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2017-06-01",
"name": "[variables('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[variables('storageAccountType')]"
},
"kind": "Storage",
View nested-template.json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"StorageAccountName": {
"type": "String",
"defaultValue": "storage2020"
}
},
"variables": {
View user-defined-function.json
"functions": [
{
"namespace": "finance",
"members": {
"prefixDepartment": {
"parameters": [
{
"name": "resourceName",
"type": "string"
}
View upload-blob-storage.cs
//Generate image
var memoryStream = GenerateBlogPostMetaCardWithDescription("{ " + metaCardDescription.PostMetaTagImageDescription + " }");
//Create the image in Blob Storage
CloudBlockBlob blob = blobContainer.GetBlockBlobReference($"{metaCardDescription.PostTitle}.png");
blob.Properties.ContentType = "image/png";
blob.UploadFromStream(memoryStream);
log.LogInformation($"Post image card generation for post {metaCardDescription.PostTitle} was successful. Image was uploaded to Blob Storage");
View generate-article-meta-card-image.cs
private static MemoryStream GenerateBlogPostMetaCardWithDescription(string description)
{
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
Bitmap newBitmap;
using (var bitmap = (Bitmap)LoadImageTemplate())//load the image file
{
View get-article-desc-github-api.cs
private static async Task<PostMetaTagImage> GetBlogPostCardDescription(ILogger log)
{
PostMetaTagImage cardDescription = new PostMetaTagImage();
try
{
string content = await MakeGitHubAPICall("https://api.github.com/repos/<website-repo>/commits");
List<CommitsData> commits = JsonConvert.DeserializeObject<List<CommitsData>>(content);
CommitsData latestCommit = commits.OrderByDescending(x => x.commit.author.date).FirstOrDefault();
View gen-order-invoice-function.cs
public static class OrderPlaceInvoiceGenerator
{
[FunctionName("OrderPlaceInvoiceGenerator")]
public static void Run([RabbitMQTrigger("medpark.orderservice/basket-service.basket_checked_out_invoice_gen", ConnectionStringSetting = "connectionStringSetting")] BasicDeliverEventArgs args,
ILogger log)
{
log.LogInformation($"Message received from RabbitMQ trigger: {message}");
}
}
View rabbitmq-trigger-ext-config-provider.cs
public class RabbitMqExtensionConfigProvider : IExtensionConfigProvider
{
private ILogger _logger;
public RabbitMqExtensionConfigProvider(ILogger logger)
{
_logger = logger;
}
public void Initialize(ExtensionConfigContext context)
View rabbitmq-binding-provider.cs
public class RabbitMqTriggerBindingProvider : ITriggerBindingProvider
{
private readonly ILogger _logger;
public RabbitMqTriggerBindingProvider(ILogger logger)
{
_logger = logger;
}
public Task<ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)