Skip to content

Commit 9738c8e

Browse files
committed
Fix up greenfield and run-mode provisioning
1 parent a1d7097 commit 9738c8e

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/Aspire.Hosting.Azure/Provisioning/Internal/DefaultProvisioningContextProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,14 @@ public async Task<ProvisioningContext> CreateProvisioningContextAsync(JsonObject
220220
// Create a unique resource group name and save it in user secrets
221221
resourceGroupName = GetDefaultResourceGroupName();
222222

223-
createIfAbsent = distributedApplicationExecutionContext.IsRunMode;
223+
createIfAbsent = true;
224224

225225
userSecrets.Prop("Azure")["ResourceGroup"] = resourceGroupName;
226226
}
227227
else
228228
{
229229
resourceGroupName = _options.ResourceGroup;
230-
createIfAbsent = distributedApplicationExecutionContext.IsRunMode && (_options.AllowResourceGroupCreation ?? false);
230+
createIfAbsent = _options.AllowResourceGroupCreation ?? false;
231231
}
232232

233233
var resourceGroups = subscriptionResource.GetResourceGroups();

src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,19 @@ await notificationService.PublishUpdateAsync(resource, state =>
170170
? context.Subscription.GetArmDeployments()
171171
: resourceGroup.GetArmDeployments();
172172

173-
var operation = await deployments.CreateOrUpdateAsync(WaitUntil.Started, resource.Name, new ArmDeploymentContent(new(ArmDeploymentMode.Incremental)
173+
var deploymentContent = new ArmDeploymentContent(new(ArmDeploymentMode.Incremental)
174174
{
175175
Template = BinaryData.FromString(armTemplateContents),
176176
Parameters = BinaryData.FromObjectAsJson(parameters),
177177
DebugSettingDetailLevel = "ResponseContent"
178-
})
179-
{ Location = context.Location },
180-
cancellationToken).ConfigureAwait(false);
178+
});
179+
// Only set the location for publish mode deployments
180+
// that are scoped to the resource
181+
if (context.ExecutionContext.IsPublishMode)
182+
{
183+
deploymentContent.Location = context.Location;
184+
}
185+
var operation = await deployments.CreateOrUpdateAsync(WaitUntil.Started, resource.Name, deploymentContent, cancellationToken).ConfigureAwait(false);
181186

182187
// Resolve the deployment URL before waiting for the operation to complete
183188
var url = GetDeploymentUrl(context, resourceGroup, resource.Name);

0 commit comments

Comments
 (0)