Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-opus-4-20250514· AnthropicHugging Face LMArena Human Preference 140K

I would to create a project in github actions, but I am pretty new to it, how to create,…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with grok-3-mini-beta’s answer.
  1. User

    I would to create a project in github actions, but I am pretty new to it, how to create, repo, push, PRs ... Basically it would a pipeline to create azure infra using BICEP (1 single BICEP file for now), I want a function app in .net that zip a txt file every time a txt file is uploaded to the storage account so for the pipeline infra it would be a resource group app service plan B1 function app and its storage account and storage account, I mean another storagre account which function app mointors when a file is uploaded and another pipeline to create the build with the function app logic in .Net and injected in the function app. I am also new to Visual studio Code so please guide me how to create the function app in it I mean what should I do in the IDE can you help me to do that?

    I want to run infra and build for function app on demand manually

  2. Claude Assistant

    I'll help you create this project step by step. Let's break this down into manageable parts:

    Part 1: Setting up GitHub and Repository

    First, let's create your GitHub repository:

    1. Create a GitHub account (if you don't have one):

    2. Create a new repository:

      • Click the "+" icon in the top right → "New repository"
      • Name it something like azure-function-zip-project
      • Make it public or private as you prefer
      • Initialize with a README
      • Click "Create repository"
    3. Clone the repository locally:

      git clone https://github.com/YOUR_USERNAME/azure-function-zip-project.git
      cd azure-function-zip-project
      

    Part 2: Project Structure

    Create this folder structure in your repository:

    azure-function-zip-project/
    ├── .github/
    │   └── workflows/
    │       ├── deploy-infrastructure.yml
    │       └── deploy-function.yml
    ├── infrastructure/
    │   └── main.bicep
    ├── src/
    │   └── FileZipperFunction/
    │       ├── FileZipperFunction.csproj
    │       ├── FileZipTrigger.cs
    │       └── host.json
    └── README.md
    

    Part 3: Create the Bicep Infrastructure File

    Create infrastructure/main.bicep:

    param location string = resourceGroup().location
    param functionAppName string = 'func-filezipper-${uniqueString(resourceGroup().id)}'
    param storageAccountName string = 'stfunc${uniqueString(resourceGroup().id)}'
    param monitoredStorageAccountName string = 'stmon${uniqueString(resourceGroup().id)}'
    param appServicePlanName string = 'asp-filezipper-${uniqueString(resourceGroup().id)}'
    
    // Storage Account for Function App
    resource functionStorageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' = {
      name: storageAccountName
      location: location
      sku: {
        name: 'Standard_LRS'
      }
      kind: 'StorageV2'
    }
    
    // Storage Account to Monitor
    resource monitoredStorageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' = {
      name: monitoredStorageAccountName
      location: location
      sku: {
        name: 'Standard_LRS'
      }
      kind: 'StorageV2'
    }
    
    // App Service Plan
    resource appServicePlan 'Microsoft.Web/serverfarms@2021-03-01' = {
      name: appServicePlanName
      location: location
      sku: {
        name: 'B1'
        tier: 'Basic'
      }
    }
    
    // Function App
    resource functionApp 'Microsoft.Web/sites@2021-03-01' = {
      name: functionAppName
      location: location
      kind: 'functionapp'
      properties: {
        serverFarmId: appServicePlan.id
        siteConfig: {
          netFrameworkVersion: 'v6.0'
          appSettings: [
            {
              name: 'AzureWebJobsStorage'
              value: 'DefaultEndpointsProtocol=https;AccountName=${functionStorageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${functionStorageAccount.listKeys().keys[0].value}'
            }
            {
              name: 'FUNCTIONS_EXTENSION_VERSION'
              value: '~4'
            }
            {
              name: 'FUNCTIONS_WORKER_RUNTIME'
              value: 'dotnet'
            }
            {
              name: 'MonitoredStorageConnection'
              value: 'DefaultEndpointsProtocol=https;AccountName=${monitoredStorageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${monitoredStorageAccount.listKeys().keys[0].value}'
            }
          ]
        }
      }
    }
    
    output functionAppName string = functionApp.name
    output monitoredStorageAccountName string = monitoredStorageAccount.name
    

    Part 4: Create the Function App in Visual Studio Code

    1. Install required tools:

      • Install Visual Studio Code
      • Install .NET 6.0 SDK or later
      • Install Azure Functions Core Tools
      • Install the Azure Functions extension in VS Code
    2. Create the Function App project:

    Create src/FileZipperFunction/FileZipperFunction.csproj:

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <AzureFunctionsVersion>v4</AzureFunctionsVersion>
      </PropertyGroup>
      <ItemGroup>
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.1" />
        <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
        <PackageReference Include="System.IO.Compression" Version="4.3.0" />
      </ItemGroup>
      <ItemGroup>
        <None Update="host.json">
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Update="local.settings.json">
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
          <CopyToPublishDirectory>Never</CopyToPublishDirectory>
        </None>
      </ItemGroup>
    </Project>
    

    Create src/FileZipperFunction/FileZipTrigger.cs:

    using System;
    using System.IO;
    using System.IO.Compression;
    using System.Threading.Tasks;
    using Microsoft.Azure.WebJobs;
    using Microsoft.Extensions.Logging;
    using Azure.Storage.Blobs;
    
    namespace FileZipperFunction
    {
        public static class FileZipTrigger
        {
            [FunctionName("FileZipTrigger")]
            public static async Task Run(
                [BlobTrigger("uploads/{name}", Connection = "MonitoredStorageConnection")] Stream myBlob,
                string name,
                [Blob("zipped/{name}.zip", FileAccess.Write, Connection = "MonitoredStorageConnection")] Stream outputBlob,
                ILogger log)
            {
                log.LogInformation($"C# Blob trigger function processing blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
    
                try
                {
                    // Create a zip archive in memory
                    using (var zipArchive = new ZipArchive(outputBlob, ZipArchiveMode.Create, true))
                    {
                        // Add the file to the zip
                        var zipEntry = zipArchive.CreateEntry(name, CompressionLevel.Optimal);
                        
                        using (var zipStream = zipEntry.Open())
                        {
                            await myBlob.CopyToAsync(zipStream);
                        }
                    }
    
                    log.LogInformation($"Successfully zipped file: {name}");
                }
                catch (Exception ex)
                {
                    log.LogError($"Error zipping file {name}: {ex.Message}");
                    throw;
                }
            }
        }
    }
    

    Create src/FileZipperFunction/host.json:

    {
        "version": "2.0",
        "logging": {
            "applicationInsights": {
                "samplingSettings": {
                    "isEnabled": true,
                    "excludedTypes": "Request"
                }
            }
        }
    }
    

    Part 5: Create GitHub Actions Workflows

    Create .github/workflows/deploy-infrastructure.yml:

    name: Deploy Infrastructure
    
    on:
      workflow_dispatch:
    
    env:
      AZURE_RESOURCEGROUP_NAME: rg-filezipper-function
      LOCATION: eastus
    
    jobs:
      deploy-infrastructure:
        runs-on: ubuntu-latest
        steps:
        - uses: actions/checkout@v3
        
        - name: Azure Login
          uses: azure/login@v1
          with:
            creds: ${{ secrets.AZURE_CREDENTIALS }}
        
        - name: Create Resource Group
          uses: azure/CLI@v1
          with:
            inlineScript: |
              az group create --name ${{ env.AZURE_RESOURCEGROUP_NAME }} --location ${{ env.LOCATION }}
        
        - name: Deploy Bicep
          uses: azure/arm-deploy@v1
          with:
            resourceGroupName: ${{ env.AZURE_RESOURCEGROUP_NAME }}
            template: ./infrastructure/main.bicep
            deploymentName: 'deploy-${{ github.run_number }}'
    

    Create .github/workflows/deploy-function.yml:

    name: Deploy Function App
    
    on:
      workflow_dispatch:
    
    env:
      AZURE_RESOURCEGROUP_NAME: rg-filezipper-function
      DOTNET_VERSION: '6.0.x'
    
    jobs:
      build-and-deploy:
        runs-on: ubuntu-latest
        steps:
        - uses: actions/checkout@v3
        
        - name: Setup .NET
          uses: actions/setup-dotnet@v3
          with:
            dotnet-version: ${{ env.DOTNET_VERSION }}
        
        - name: Azure Login
          uses: azure/login@v1
          with:
            creds: ${{ secrets.AZURE_CREDENTIALS }}
        
        - name: Get Function App Name
          id: getfunctionapp
          uses: azure/CLI@v1
          with:
            inlineScript: |
              functionAppName=$(az functionapp list -g ${{ env.AZURE_RESOURCEGROUP_NAME }} --query "[0].name" -o tsv)
              echo "FUNCTION_APP_NAME=$functionAppName" >> $GITHUB_OUTPUT
        
        - name: Build Function App
          run: |
            cd src/FileZipperFunction
            dotnet restore
            dotnet build --configuration Release
            dotnet publish -c Release -o ./publish
        
        - name: Deploy to Azure Functions
          uses: Azure/functions-action@v1
          with:
            app-name: ${{ steps.getfunctionapp.outputs.FUNCTION_APP_NAME }}
            package: './src/FileZipperFunction/publish'
    

    Part 6: Setting up Azure Credentials

    1. Create an Azure Service Principal:

      az ad sp create-for-rbac --name "github-actions-sp" --role contributor --scopes /subscriptions/{subscription-id} --sdk-auth
      
    2. Copy the JSON output and add it as a GitHub secret:

      • Go to your GitHub repository → Settings → Secrets and variables → Actions
      • Click "New repository secret"
      • Name: AZURE_CREDENTIALS
      • Value: Paste the JSON output

    Part 7: Pushing Code and Creating PRs

    1. Add and commit your files:

      git add .
      git commit -m "Initial project setup with infrastructure and function app"
      
    2. Push to GitHub:

      git push origin main
      
    3. Creating Pull Requests (for future changes):

      # Create a new branch
      git checkout -b feature/my-new-feature
      
      # Make your changes
      # Add and commit
      git add .
      git commit -m "Add new feature"
      
      # Push the branch
      git push origin feature/my-new-feature
      

      Then go to GitHub and you'll see a prompt to create a Pull Request.

    Part 8: Running the Pipelines

    1. Go to your GitHub repository
    2. Click on "Actions" tab
    3. You'll see two workflows:
      • "Deploy Infrastructure" - Run this first
      • "Deploy Function App" - Run this after infrastructure is deployed
    4. Click on a workflow → "Run workflow" → "Run workflow"

    Testing Your Function

    After deployment:

    1. Go to Azure Portal
    2. Find your monitored storage account
    3. Create a container called "uploads"
    4. Create a container called "zipped"
    5. Upload a .txt file to the "uploads" container
    6. Check the "zipped" container for the zipped file

    This setup gives you a complete CI/CD pipeline with manual triggers for both infrastructure and function app deployment. The function will automatically zip any text file uploaded to the monitored storage account.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.