存储架构

Using Azure PowerShell Commands To Create An App Service Web App

微信扫一扫,分享到朋友圈

Using Azure PowerShell Commands To Create An App Service Web App
0

Using Azure PowerShell Commands To Create An App Service Web App

Azure PowerShell provides a set of cmdlets that use the Azure Resource Manager model for managing your Azure resources. You can use it in your browser with Azure Cloud Shell, or you can install it on your local machine and use it in any PowerShell session.

  • 192

Azure PowerShell

Azure PowerShell provides a set of cmdlets that use the Azure Resource Manager model for managing your Azure resources. You can use it in your browser with Azure Cloud Shell, or you can install it on your local machine and use it in any PowerShell session. Use the Cloud Shell to run the Azure PowerShell in your browser, or install it on own computer.

Creating a Web App with Azure PowerShell

Creating an Azure Services Web App with Azure PowerShell follows a consistent pattern, 

  1. Create a basic MVC Web App
  2. Create the resource group
  3. Create the App Service Plan
  4. Create a web app
  5. Deploy the app

First, we need to create a simple web application for deployment purpose.

From visual studio select File > New > Project > Web > ASP.NET Core Web Aplication.

Set Project Name and click OK.

Select Web Application Template and click OK.

Next, build the project.

Then, right click on the project and select "Publish".

Select the destination and choose a target folder that will contain all publisher files.

Once deployed locally, navigate to the location where you stored the local deployment, select all, and zip them up.

Next, we need to write a PowerShell script to deploy on to Azure.

Go to Azure Portal https://portal.azure.com and from the top bar, click on Cloud Shell.

Azure Cloud Shell requires an Azure file share to persist files. So, we will create a new storage account for that. Select your subscription and click on "Create Storage" button.

From upload/download files, we need to upload the WebApplicationDemo.deps.zip that be created in the previous steps. 

Then, type the below script. This is the script for creating a web app, and for deployment of the app from a local machine.

#Defined the Web Application Name and location  
$webappname="DemoWebAppSbeeh1" 
$location="West Europe" 
$AppServicePlan="DemoWebApps" 

#Create a resource group.  
New-AzureRmResourceGroup -Name DemoResourceGroup -Location $location  

#Create an App Service plan in Free tier.  
 New-AzureRmAppServicePlan -Name $AppServicePlan -Location $location -ResourceGroupName DemoResourceGroup -Tier Free  

#Create a web app.   
New-AzureRmWebApp -Name $webappname -Location $location -AppServicePlan $AppServicePlan -ResourceGroupName DemoResourceGroup  

#Publish Web App  
Publish-AzWebApp -ResourceGroupName DemoResourceGroup -Name $webappname -ArchivePath WebApplicationDemo.deps.zip  

Now, we need to test the web app by clicking the Web URL.

Clean Up Deployment

After the script sample has been run, the following command can be used to remove the resource group, web app, and all related resources.

Remove-AzureRmResourceGroup -Name DemoResourceGroup -Force  

Thank you for reading!

阅读原文...

微信扫一扫,分享到朋友圈

Using Azure PowerShell Commands To Create An App Service Web App
0
C-Sharpcorner

unity3d俄罗斯方块源码教程+源码和程序下载

上一篇

Nobody wants a Bitcoin ETF because cryptocurrency ‘has no intrinsic value’

下一篇

评论已经被关闭。

插入图片

热门分类

往期推荐

Using Azure PowerShell Commands To Create An App Service Web App

长按储存图像,分享给朋友