简体   繁体   中英

Create an Azure Web App Using C#

Hi I'm currently refreshing my knowledge in C# programming.

I wanted to translate the manual way of creating a Web App in Microsoft Azure (Classic) into the C# language.

(Manual way - New > Compute > Web App > Custom Create > ...etc.. )

Whenever I search through google about this topic all it gives me is to literally create a "WebApp" in Visual Studio. (File > New > ...etc...) However, what I am looking for is how to create an Azure Web App programatically via C# - how to interact with the Management UI of the Classic Azure Portal to create a web app.

Anyone familiar to do this? Thanks in advance for the help! :)

To create an azure website easily using C#, you can use "Windows Azure Management Libraries". This SDK is a wrapper arround "Azure Service Management" API.

Here is a introduction from Braddy Gaster an a blog post , to get credentials from an Azure Tenant an work with ASM Api.

Then you will be able to create a website with something like this :

using (var AwsManagement = new Microsoft.WindowsAzure.Management.WebSites.WebSiteManagementClient(azureCredentials))
{

    WebSiteCreateParameters parameters = new WebSiteCreateParameters()
    {
            Name = "myAws",
            // this Service Plan must be created before
            ServerFarm = "myServiceplan",
     };

      await AwsManagement.WebSites.CreateAsync("myWebSpace", parameters, CancellationToken.None);
}

I was able to work on the available code Microsoft posted in GitHub:

https://github.com/Azure/azure-sdk-for-net

I re-coded some and just acquired the functions that I only need for my program to work. :)

You can create a web site by using a POST request that includes the name of the web site and other information in the request body. You can check the code example for ASM here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM