Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Azure Batch #1

Merged
merged 1 commit into from
May 17, 2024
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
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
Loading