I realize @Alexandre , that the quick start guide doesn't mention app service. I believe the reason being is because App Service SDK is still in beta according https://azure.github.io/azure-sdk/releases/latest/mgmt/dotnet.html. But in looking at the quick start and Azure AppService Management client library for .NET, I think it would be something similar to this
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.AppService;
using Azure.ResourceManager.AppService.Models;
using Azure.ResourceManager.Resources;
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Let's get it started HA!!...");
Console.WriteLine("Enter resource group: ");
string? resourceGroupName = Console.ReadLine();
ArmClient client = new ArmClient(new DefaultAzureCredential());
SubscriptionResource subscription = await client.GetDefaultSubscriptionAsync();
ResourceGroupCollection resourceGroups = subscription.GetResourceGroups();
ResourceGroupResource resourceGroup = await resourceGroups.GetAsync(resourceGroupName);
Console.WriteLine("Getting app services...");
await foreach (WebSiteResource webSiteResource in resourceGroup.GetWebSites())
{
Console.WriteLine($"Web site: {webSiteResource.Data}");
}
WebSiteCollection webSites = resourceGroup.GetWebSites();
WebSiteData website = webSites.SingleOrDefault(w => w.Data.Name == "mywebsite")?.Data ?? new WebSiteData(AzureLocation.EastUS);
ArmOperation<WebSiteResource> operation = await webSites.CreateOrUpdateAsync(WaitUntil.Completed, "mywebsite", website);
Now two things, I don't create the app service plan here. This would be dependent on how you intend to deploy resources since you mentioned retrieving an existing resource. Secondly, this snippet doesn't have any deployment. Which again will depend heavily on how you intend to deploy resources; but what I would suggest doing is retrieving WebSiteResource
collection, iterating through, and inspecting the Data property to give you an idea on how to setup your objects.
---
EDIT 2022 Aug 18 To benefit the broader community, App Services SDK is currently still evolving. Therefore, there are some gaps and samples aren't ready. However, the team is perceptive to feedback. Follow this GitHub issue for updates and providing feedback.
I'm no expert on the SDK but trying
CreateOrUpdate(WaitUntil, String, DeploymentData, CancellationToken)
under SiteDeploymentCollection object. The only issue is I have no idea how to use DeploymentData. What I would suggest is continue using the version of the SDK you're familiar with and submit an issue to the team asking how the new SDK deploys resources.Yes I discovered this method too and it seems a good lead, however I did not find out how to use the DeploymentData object as well. I created the issue : https://github.com/Azure/azure-sdk-for-net/issues/30520