Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public StorageAccount(IConstruct scope, StorageKind kind, StorageSkuName sku, Re
sku: new StorageSku(sku),
kind: StorageKind.StorageV2))
{
if (scope.Configuration?.UsePromptMode == true)
{
AssignProperty(data => data.Name, $"toLower(take(concat('{name}', uniqueString(resourceGroup().id)), 24))");
}
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
targetScope = 'resourceGroup'


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

resource blobService_OdYIZd2T2 'Microsoft.Storage/storageAccounts/blobServices@2022-09-01' = {
parent: storageAccount_Ls2Cd9uGu
name: 'default'
properties: {
}
}
19 changes: 15 additions & 4 deletions sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ await ValidateBicepAsync(BinaryData.FromObjectAsJson(
{
sqlAdminPassword = new { value = "password" },
appUserPassword = new { value = "password" }
}), anonymousResourceGroup: true);
}), promptMode: true);
}

[Test]
Expand All @@ -207,6 +207,17 @@ public async Task StorageBlobDefaults()
await ValidateBicepAsync();
}

[Test]
public async Task StorageBlobDefaultsInPromptMode()
{
var infra = new TestInfrastructure(configuration: new Configuration { UsePromptMode = true });
infra.AddStorageAccount(name: "photoAcct", sku: StorageSkuName.PremiumLrs, kind: StorageKind.BlockBlobStorage);
infra.AddBlobService();
infra.Build(GetOutputPath());

await ValidateBicepAsync(promptMode: true);
}

[Test]
public async Task StorageBlobDropDown()
{
Expand Down Expand Up @@ -280,7 +291,7 @@ public async Task OutputsSpanningModules()
await ValidateBicepAsync();
}

public async Task ValidateBicepAsync(BinaryData? parameters = null, bool anonymousResourceGroup = false)
public async Task ValidateBicepAsync(BinaryData? parameters = null, bool promptMode = false)
{
if (TestEnvironment.GlobalIsRunningInCI)
{
Expand Down Expand Up @@ -317,7 +328,7 @@ public async Task ValidateBicepAsync(BinaryData? parameters = null, bool anonymo
}

ResourceIdentifier scope;
if (anonymousResourceGroup)
if (promptMode)
{
var rgs = subscription.GetResourceGroups();
var data = new ResourceGroupData("westus");
Expand All @@ -337,7 +348,7 @@ public async Task ValidateBicepAsync(BinaryData? parameters = null, bool anonymo
Template = new BinaryData(File.ReadAllText(Path.Combine(testPath, "main.json"))),
Parameters = parameters
});
if (!anonymousResourceGroup)
if (!promptMode)
{
content.Location = "westus";
}
Expand Down