Posts

Create Web APP/App Service

Login-AzureRmAccount Set-AzureRmContext -SubscriptionId "subid" $ResourceGroupName='powershelltest' $Location='Southeast Asia' $servername='testsqlserver12345' $webappname='testwebapp12345678911' $AppServicePlan='testplan' New-AzureRmWebApp -Name $webappname -Location $Location ` -AppServicePlan $AppServicePlan -ResourceGroupName $ResourceGroupName

create azure sql database

Login-AzureRmAccount Set-AzureRmContext -SubscriptionId "subid" $ResourceGroupName='powershelltest' $Location='Southeast Asia' $servername='testsqlserver12345' $databasename='testdb' New-AzureRmSqlDatabase  -ResourceGroupName $ResourceGroupName `     -ServerName $servername `     -DatabaseName $databasename `     -SampleName "AdventureWorksLT" `     -RequestedServiceObjectiveName "S0"

Create Azure SQL Server Firewall rule

Login-AzureRmAccount Set-AzureRmContext -SubscriptionId "8eda5ce0-6efa-4f1e-a926-8c28b48bba08" $ResourceGroupName='powershelltest' $Location='Southeast Asia' $servername='testsqlserver12345' $startip='0.0.0.0' $endip='255.255.255.255' New-AzureRmSqlServerFirewallRule -ResourceGroupName $ResourceGroupName `     -ServerName $servername `     -FirewallRuleName "AllowALL" -StartIpAddress $startip -EndIpAddress $endip

create azure sql server

Login-AzureRmAccount Set-AzureRmContext -SubscriptionId "sub id" $ResourceGroupName='powershelltest' $Location='Southeast Asia' $servername='testsqlserver12345' $adminlogin='admin12345' $password='DBAdmin@123456' New-AzureRmSqlServer -ResourceGroupName $ResourceGroupName `     -ServerName $servername `     -Location $Location `     -SqlAdministratorCredentials $(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $adminlogin, $(ConvertTo-SecureString -String $password -AsPlainText -Force))

Create App Service Plan

Login-AzureRmAccount Set-AzureRmContext -SubscriptionId "your subcription id" $ResourceGroupName='test-rg' $Location='Southeast Asia' $AppServicePlanName='testplan' $functionplan=Get-AzureRmAppServicePlan -ResourceGroupName $ResourceGroupName -Name $AppServicePlanName -ErrorAction Ignore if(($functionplan| Measure-Object).Count -eq 0) {     $functionplan=New-AzureRmAppServicePlan -ResourceGroupName $ResourceGroupName -Name $AppServicePlanName -Location $location -Tier "Standard" -WorkerSize "Small" }

Create log analytics work space

Login-AzureRmAccount Set-AzureRmContext -SubscriptionId "your subcription id" $ResourceGroupName='test-rg' $WorkspaceName='tets-ws' $Location='Southeast Asia' $ws=Get-AzureRmOperationalInsightsWorkspace -Name $WorkspaceName -ResourceGroupName $ResourceGroupName -ErrorAction Ignore if(($ws | Measure-Object).Count -eq 0) {     $ws = New-AzureRmOperationalInsightsWorkspace -Location $location -Name $WorkspaceName -sku $LogAnalytcisSKU -ResourceGroupName $ResourceGroupName }

Create Automation Account with Powershell

Login-AzureRmAccount Set-AzureRmContext -SubscriptionId "your subcription id" $ResourceGroupName='test-rg'     $aaName='testaa' $Location='Southeast Asia'     $aa=Get-AzureRmAutomationAccount -ResourceGroupName $ResourceGroupName -Name $aaName -ErrorAction Ignore     if(($aa | Measure-Object).Count -eq 0) {         $aa = New-AzureRmAutomationAccount -Name $aaName -Location $Location -ResourceGroupName $ResourceGroupName     }