-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from WhitWaldo/azure-batch
Added support for Azure Batch
- Loading branch information
Showing
9 changed files
with
894 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
using Achieve.Aspire.AzureProvisioning.Bicep.Batch; | ||
using Achieve.Aspire.AzureProvisioning.Bicep.Internal; | ||
using Achieve.Aspire.AzureProvisioning.Resources; | ||
using Aspire.Hosting; | ||
using Aspire.Hosting.ApplicationModel; | ||
using Aspire.Hosting.Azure; | ||
|
||
namespace Achieve.Aspire.AzureProvisioning; | ||
|
||
public static class Batch | ||
{ | ||
public static IResourceBuilder<AzureBatchResource> AddAzureBatchAccount(this IDistributedApplicationBuilder builder, string name, Action<BatchAccountOptions> configure) | ||
{ | ||
builder.AddAzureProvisioning(); | ||
|
||
var accountResource = new BatchAccountResource(name); | ||
var options = new BatchAccountOptions(accountResource); | ||
configure(options); | ||
|
||
var fileOutput = BicepFileOutput.GetAspireFileOutput(); | ||
fileOutput.AddResource(accountResource); | ||
foreach (var certificate in options.Certificates) | ||
{ | ||
fileOutput.AddResource(certificate.Value.Resource); | ||
} | ||
|
||
var resource = new AzureBatchResource(name, fileOutput); | ||
var resourceBuilder = builder.AddResource(resource); | ||
|
||
return resourceBuilder.WithManifestPublishingCallback(resource.WriteToManifest); | ||
} | ||
|
||
public class AzureBatchResource(string name, BicepFileOutput bicepFileOutput) | ||
: AchieveResource(name, bicepFileOutput) | ||
{ | ||
public const string BatchResourceName = "resourceName"; | ||
|
||
public BicepOutputReference AccountEndpoint => new(BatchResourceName, this); | ||
} | ||
} | ||
|
||
public class BatchAccountOptions(BatchAccountResource resource) | ||
{ | ||
public BatchAccountResource Resource { get; set; } = resource; | ||
|
||
public Dictionary<string, BatchCertificateOptions> Certificates { get; set; } = []; | ||
|
||
public BatchCertificateOptions AddCertificate(string name, Action<BatchCertificateResource>? configure = null) | ||
{ | ||
var certificate = new BatchCertificateResource(Resource, name); | ||
configure?.Invoke(certificate); | ||
Certificates.Add(name, new BatchCertificateOptions(this, certificate)); | ||
return Certificates[name]; | ||
} | ||
} | ||
|
||
public class BatchCertificateOptions(BatchAccountOptions parent, BatchCertificateResource certificate) | ||
{ | ||
public BatchCertificateResource Resource { get; set; } = certificate; | ||
} |
Oops, something went wrong.