Skip to content

Commit

Permalink
Merge pull request #1 from WhitWaldo/azure-batch
Browse files Browse the repository at this point in the history
Added support for Azure Batch
  • Loading branch information
rudiv authored May 17, 2024
2 parents 765de5d + eb0a69b commit 30ac6c8
Show file tree
Hide file tree
Showing 9 changed files with 894 additions and 2 deletions.
61 changes: 61 additions & 0 deletions src/Achieve.Aspire.AzureProvisioning/Batch.cs
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)

Check warning on line 58 in src/Achieve.Aspire.AzureProvisioning/Batch.cs

View workflow job for this annotation

GitHub Actions / test

Parameter 'parent' is unread.
{
public BatchCertificateResource Resource { get; set; } = certificate;
}
Loading

0 comments on commit 30ac6c8

Please sign in to comment.