Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.47k stars 4.8k forks source link

[FEATURE REQ] When in prompt mode, Infrastructure pre-adds `param location string = resourceGroup().location`. #42276

Closed mitchdenny closed 8 months ago

mitchdenny commented 8 months ago

Library name

Azure.Provisioning

Please describe the feature.

When in prompt mode we need the CDK to prepend the following parameter to the construct:

param location string = resourceGroup().location

This parameter would then be used whenever a resource is added to the construct. The following Aspire code:

var construct1 = builder.AddAzureConstruct("construct1", (construct) =>
{
    var account = construct.AddStorageAccount(
        name: "bob",
        kind: StorageKind.BlobStorage,
        sku: StorageSkuName.StandardLrs
        );

    account.AddOutput(data => data.PrimaryEndpoints.TableUri, "tableUri", isSecure: true);
});

... would result in the following Bicep:

targetScope = 'resourceGroup'

param location string = resourceGroup().location

resource storageAccount_SOTvKjFQy 'Microsoft.Storage/storageAccounts@2022-09-01' = {
  name: toLower(take(concat('bob', uniqueString(resourceGroup().id)), 24))
  location: location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
  properties: {
  }
}

output tableUri string = storageAccount_SOTvKjFQy.properties.primaryEndpoints.table
mitchdenny commented 8 months ago

/cc @JoshLove-msft @m-nash @tg-msft @vhvb1989