Skip to content

tobiso95/th-gh-actions-sample

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Actions sample repository

Instructions

  • Fork the repository to your own GitHub account.
  • Go to your Azure Function and download your publish profile.
  • Add a GitHub secret using PUBLISHSETTINGS for the Name and the content of the publishing profile for the Value.
  • In the .github/workflows/fred-api-cicd.yml workflow in Line 10, change the INITIALS environment variable to your initals and commit the changes to the main branch.
  • Go to the Actions view and enable them by clicking the green "I understand my workflows, go ahead and enable them" button
  • Select the .github/workflows/fred-api-cicd.yml workflow and run it using the Run workflow button. (See: Running a workflow on GitHub)
  • After the workflow run you can test the deployment by calling the following URL: https://<INITALS>-fredapi-func-dev.azurewebsites.net/api/SayHello?name=<YOURNAME>

Bonus: Scaffolding the function and infrastructure

This section contains information on how we have created the sample.

Prerequisites

Azure Function project

  • Create a local Functions project and select dotnet for the worker runtime:

    func init FredApi
  • Create a function with a HTTP trigger

    cd FredApi
    func new --name SayHello --template 'HTTP trigger'

Azure infrastructure

The following script creates a resource group with a storage account and an azure function app

$initials = 'mbr'
$storageAccountName = '{0}0fredapi0dev0stac' -f $initials
$functionappname = '{0}-fredapi-func-dev' -f $initials
$functionAppPlanName = '{0}-fredapi-asp-dev' -f $initials
$resourceGroupName = 'rg-{0}-fredapi-dev' -f $initials

# Create a resource group.
az group create `
  --name $resourceGroupName `
  --location $region

# Create an Azure storage account in the resource group.
az storage account create `
  --name $storageAccountName `
  --location $region `
  --resource-group $resourceGroupName `
  --sku Standard_LRS

# Create an appservice plan
az appservice plan create `
  --name $functionAppPlanName `
  --resource-group $resourceGroupName `
  --location $region `
  --sku B1

# Create a function app in the resource group.
az functionapp create `
    --name $functionAppName `
    --plan $functionAppPlanName `
    --storage-account $storageAccountName `
    --resource-group $resourceGroupName `
    --disable-app-insights `
    --functions-version 3

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PowerShell 53.7%
  • C# 46.3%