Posts

Showing posts from June, 2018

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     }

Create Key Vault with Powershell

Login-AzureRmAccount Set-AzureRmContext -SubscriptionId "your subcription id" $ResourceGroupName='test-rg' $vaultName='testvault' $Location='Southeast Asia' $keyv=Get-AzureRMKeyVault -VaultName $vaultName -ResourceGroupName $ResourceGroupName if(($keyv | Measure-Object).Count -eq 0) {       $keyv = New-AzureRmKeyVault -VaultName $vaultName -ResourceGroupName $ResourceGroupName -Location $Location }

Create application insights with Powershell

Create application insights with Powershell Login-AzureRmAccount Set-AzureRmContext -SubscriptionId "your subcription id" $ResourceGroupName='test-rg' $Location='Southeast Asia' [string] $ResourceType = "Microsoft.Insights/components"; $AppInsightName='tetsai' $ra = Get-AzureRmResource  -ResourceGroupName $ResourceGroupName -ResourceType $ResourceType -Name $AppInsightName if(($ra | Measure-Object).Count -eq 0) {   $ra = New-AzureRmResource -ResourceName $AppInsightName -ResourceGroupName $ResourceGroupName -ResourceType $ResourceType ` -Location $Location -PropertyObject @{"Application_Type"="web"} -Force }

Create Storage Container with Powershell

This Script will ask login details and then sets the context for your subscription id. Then it tries to retrieve storage account inside given resource group and creates tries to find container inside storage account and if not found then creates it. Login-AzureRmAccount Set-AzureRmContext -SubscriptionId "your subcription id" $ResourceGroupName='test-rg' $Location='Southeast Asia' $storageSku = "Standard_LRS"; $StorageAccountName='testsa' #it should be unique $StorageAccount = Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName  -ErrorAction Ignore $containerName='testcontainer' $container = Get-AzureStorageContainer -Context $StorageAccount.Context -Name $containerName -ErrorAction Ignore if(($container| Measure-Object).Count -eq 0) {    $container = New-AzureStorageContainer -Context $StorageAccount.Context -Name $containerName -Permission 'Off' }

Create Storage Group with Powershell

This Script will ask login details and then sets the context for your subscription id. Then it tries to find storage account inside given resource group  and if not found then it creates with the same name. Login-AzureRmAccount Set-AzureRmContext -SubscriptionId "your subcription id" $ResourceGroupName='test-rg' $Location='Southeast Asia' $storageSku = "Standard_LRS"; $StorageAccountName='testsa' #it should be unique $SAccount = Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName  -ErrorAction Ignore if(-not $SAccount) {     $SAccount=  New-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName `     -Name $StorageAccountName `     -Type $storageSku `     -Location $Location `     -Kind Storage `     -EnableHttpsTrafficOnly $true `     -ErrorAction Stop }