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

Add Charming library to the list #1204

Merged
merged 1 commit into from
Jun 13, 2023
Merged

Add Charming library to the list #1204

merged 1 commit into from
Jun 13, 2023

Conversation

tzkhan
Copy link
Contributor

@tzkhan tzkhan commented May 16, 2020

Charming is a small, lightweight library that lets you generate ARM templates using C#.

@Apollo9999
Copy link
Contributor

Apollo9999 commented May 29, 2023

.NET, which provide a set of client libraries for interacting with Azure resources. These libraries allow you to programmatically create and manage Azure resources, including the generation of ARM templates.

Here's a brief example of how you can use the Azure Management Libraries for .NET (specifically the Microsoft.Azure.Management.ResourceManager package) to generate an ARM template using C#:

using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.ResourceManager.Models;
using Newtonsoft.Json;

class Program
{
static void Main()
{
// Create a new instance of the ResourceManagementClient
var credentials = SdkContext.AzureCredentialsFactory.FromFile("<path_to_azure_credentials>");
var resourceManagementClient = new ResourceManagementClient(credentials);

    // Create a resource group
    var resourceGroupName = "myResourceGroup";
    resourceManagementClient.ResourceGroups.CreateOrUpdate(resourceGroupName, new ResourceGroup { Location = "westus2" });

    // Generate ARM template for the resource group
    var exportResult = resourceManagementClient.ResourceGroups.ExportTemplate(resourceGroupName, new ExportTemplateRequest { IncludeParameterDefaultValue = true });

    // Serialize the ARM template to JSON
    var armTemplateJson = JsonConvert.SerializeObject(exportResult.Template, Formatting.Indented);

    // Output the ARM template
    Console.WriteLine(armTemplateJson);
}

}

@mairaw mairaw closed this Jun 13, 2023
@mairaw mairaw reopened this Jun 13, 2023
@richlander richlander merged commit 19024e9 into microsoft:main Jun 13, 2023
@Apollo9999
Copy link
Contributor

Thanks a lot

Mattes0h pushed a commit to Mattes0h/dotnet that referenced this pull request Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants