Skip to content

Comments

Fix storage account connection string configuration in Infrastructure as Code#69

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-68
Draft

Fix storage account connection string configuration in Infrastructure as Code#69
Copilot wants to merge 2 commits intomainfrom
copilot/fix-68

Conversation

Copy link

Copilot AI commented Jul 17, 2025

Summary

This PR fixes the runtime error in the cpu-app where the /api/app/test endpoint was throwing InvalidOperationException: Storage account connection string is not configured.

Problem

The application code was correctly looking for a storage account connection string via app.GetConnectionString("StorageAccount"), but the infrastructure deployment (main.bicep) was not provisioning a storage account or configuring the connection string in the web app's settings.

Solution

Updated the Bicep template to:

  1. Add Azure Storage Account resource - Provisions a Standard_LRS storage account with secure defaults
  2. Configure connection string in app settings - Sets ConnectionStrings__StorageAccount which maps to ConnectionStrings:StorageAccount in .NET Core configuration
  3. Add storage account name output - Provides visibility into the provisioned storage account

Changes Made

  • main.bicep: Added storage account resource and app setting configuration
  • .gitignore: Added main.json to exclude generated ARM templates

Technical Details

The connection string is dynamically generated using the storage account's name and primary key:

{
  name: 'ConnectionStrings__StorageAccount'
  value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};AccountKey=${storageAccount.listKeys().keys[0].value};EndpointSuffix=core.windows.net'
}

This resolves the runtime error while maintaining minimal changes to the existing codebase.

Fixes #68.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: bicep build main.bicep (dns block)
    • Triggering command: bicep build main.bicep --stdout (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: mrsharm <68247673+mrsharm@users.noreply.github.com>
Copilot AI changed the title [WIP] [cpu-app] Storage account connection string not configured - runtime error and missing IaC configuration Fix storage account connection string configuration in Infrastructure as Code Jul 17, 2025
Copilot AI requested a review from mrsharm July 17, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cpu-app] Storage account connection string not configured - runtime error and missing IaC configuration

2 participants