forked from Azure/azure-docs-powershell-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added scripts for Connect, Monitor and Scale
- Loading branch information
Showing
5 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
# Generates a Random Value | ||
$Random=(New-Guid).ToString().Substring(0,8) | ||
|
||
# Variables | ||
$ResourceGroup="MyResourceGroup$Random" | ||
$AppName="webappwithSQL$Random" | ||
$Location="West US" | ||
$ServerName="webappwithsql$Random" | ||
$StartIP="0.0.0.0" | ||
$EndIP="0.0.0.0" | ||
$Username="ServerAdmin" | ||
$Password="<provide-a-password>" | ||
$SqlServerPassword=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username,(ConvertTo-SecureString -String $Password -AsPlainText -Force) | ||
|
||
# Create a Resource Group | ||
New-AzureRMResourceGroup -Name $ResourceGroup -Location $Location | ||
|
||
# Create an App Service Plan | ||
New-AzureRMAppservicePlan -Name WebAppwithSQLPlan -ResourceGroupName $ResourceGroup -Location $Location -Tier Basic | ||
|
||
# Create a Web App in the App Service Plan | ||
New-AzureRMWebApp -Name $AppName -ResourceGroupName $ResourceGroup -Location $Location -AppServicePlan WebAppwithSQLPlan | ||
|
||
# Create a SQL Database Server | ||
New-AzureRMSQLServer -ServerName $ServerName -Location $Location -SqlAdministratorCredentials $SqlServerPassword -ResourceGroupName $ResourceGroup | ||
|
||
# Create Firewall Rule for SQL Database Server | ||
New-AzureRmSqlServerFirewallRule -FirewallRuleName "AllowYourIp" -StartIpAddress $StartIP -EndIPAddress $EndIP -ServerName $ServerName -ResourceGroupName $ResourceGroup | ||
|
||
# Create SQL Database in SQL Database Server | ||
New-AzureRMSQLDatabase -ServerName $ServerName -DatabaseName MySampleDatabase -ResourceGroupName $ResourceGroup | ||
|
||
# Assign Connection String to Connection String | ||
Set-AzureRMWebApp -ConnectionStrings @{ MyConnectionString = @{ Type="SQLAzure"; Value ="Server=tcp:$ServerName.database.windows.net;Database=MySampleDatabase;User ID=$Username@$ServerName;Password=$password;Trusted_Connection=False;Encrypt=True;" } } -Name $AppName -ResourceGroupName $ResourceGroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
# Generates a Random Value | ||
$Random=(New-Guid).ToString().Substring(0,8) | ||
|
||
# Variables | ||
$ResourceGroup="MyResourceGroup$Random" | ||
$AppName="webappwithStorage$Random" | ||
$StorageName="webappstorage$Random" | ||
$Location="West US" | ||
|
||
# Create a Resource Group | ||
New-AzureRMResourceGroup -Name $ResourceGroup -Location $Location | ||
|
||
# Create an App Service Plan | ||
New-AzureRMAppservicePlan -Name WebAppwithStoragePlan -ResourceGroupName $ResourceGroup -Location $Location -Tier Basic | ||
|
||
# Create a Web App in the App Service Plan | ||
New-AzureRMWebApp -Name $AppName -ResourceGroupName $ResourceGroup -Location $Location -AppServicePlan WebAppwithStoragePlan | ||
|
||
# Create Storage Account | ||
New-AzureRMStorageAccount -Name $StorageName -ResourceGroupName $ResourceGroup -Location $Location -SkuName Standard_LRS | ||
|
||
# Get Connection String for Storage Account | ||
$StorageKey=(Get-AzureRMStorageAccountKey -ResourceGroupName $ResourceGroup -Name $StorageName).Value[0] | ||
|
||
# Assign Connection String to App Setting | ||
Set-AzureRMWebApp -ConnectionStrings @{ MyStorageConnStr = @{ Type="Custom"; Value="DefaultEndpointsProtocol=https;AccountName=$StorageName;AccountKey=$StorageKey;" } } -Name $AppName -ResourceGroupName $ResourceGroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
# Generates a Random Value | ||
$Random=(New-Guid).ToString().Substring(0,8) | ||
|
||
# Variables | ||
$ResourceGroupName="myResourceGroup$Random" | ||
$AppName="AppServiceMonitor$Random" | ||
$Location="WestUS" | ||
|
||
# Create a Resource Group | ||
New-AzureRMResourceGroup -Name $ResourceGroupName -Location $Location | ||
|
||
# Create an App Service Plan | ||
New-AzureRMAppservicePlan -Name AppServiceMonitorPlan -ResourceGroupName $ResourceGroupName -Location $Location -Tier Basic | ||
|
||
# Create a Web App in the App Service Plan | ||
New-AzureRMWebApp -Name $AppName -ResourceGroupName $ResourceGroupName -Location $Location -AppServicePlan AppServiceMonitorPlan | ||
|
||
# Enable Logs | ||
Set-AzureRMWebApp -RequestTracingEnabled $True -HttpLoggingEnabled $True -DetailedErrorLoggingEnabled $True -ResourceGroupName $ResourceGroupName -Name $AppName | ||
|
||
# Make a Request | ||
Invoke-WebRequest -Method "Get" -Uri https://$AppName.azurewebsites.net/404 -ErrorAction SilentlyContinue | ||
|
||
# Download the Web App Logs | ||
#Get-AzureRMWebAppMetrics -ResourceGroupName $ResourceGroupName -Name $AppName -Metrics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
# Generates a Random Value | ||
$Random=(New-Guid).ToString().Substring(0,8) | ||
|
||
# Variables | ||
$ResourceGroupName="myResourceGroup$Random" | ||
$App1Name="AppServiceTM1$Random" | ||
$App2Name="AppServiceTM2$Random" | ||
$Location1="WestUS" | ||
$Location2="EastUS" | ||
|
||
# Create a Resource Group | ||
New-AzureRMResourceGroup -Name $ResourceGroupName -Location $Location1 | ||
|
||
# Create Traffic Manager Profile | ||
New-AzureRMTrafficManagerProfile -Name "$ResourceGroupName-tmp" -ResourceGroupName $ResourceGroupName -TrafficRoutingMethod Performance -MonitorPath '/' -MonitorProtocol "HTTP" -RelativeDnsName $ResourceGroupName -Ttl 30 -MonitorPort 80 | ||
|
||
# Create an App Service Plan | ||
New-AzureRMAppservicePlan -Name "$App1Name-Plan" -ResourceGroupName $ResourceGroupName -Location $Location1 -Tier Standard | ||
New-AzureRMAppservicePlan -Name "$App2Name-Plan" -ResourceGroupName $ResourceGroupName -Location $Location2 -Tier Standard | ||
|
||
# Create a Web App in the App Service Plan | ||
$App1ResourceId=(New-AzureRMWebApp -Name $App1Name -ResourceGroupName $ResourceGroupName -Location $Location1 -AppServicePlan "$App1Name-Plan").Id | ||
$App2ResourceId=(New-AzureRMWebApp -Name $App2Name -ResourceGroupName $ResourceGroupName -Location $Location2 -AppServicePlan "$App2Name-Plan").Id | ||
|
||
# Create Traffic Manager Endpoints for Web Apps | ||
New-AzureRMTrafficManagerEndpoint -Name "$App1Name-$Location1" -ResourceGroupName $ResourceGroupName -ProfileName "$ResourceGroupName-tmp" -Type AzureEndpoints -TargetResourceId $App1ResourceId -EndpointStatus "Enabled" | ||
New-AzureRMTrafficManagerEndpoint -Name "$App2Name-$Location2" -ResourceGroupName $ResourceGroupName -ProfileName "$ResourceGroupName-tmp" -Type AzureEndpoints -TargetResourceId $App2ResourceId -EndpointStatus "Enabled" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
# Generates a Random Value | ||
$Random=(New-Guid).ToString().Substring(0,8) | ||
|
||
# Variables | ||
$ResourceGroupName="myResourceGroup$random" | ||
$AppName="AppServiceManualScale$random" | ||
$Location="WestUS" | ||
|
||
# Create a Resource Group | ||
New-AzureRMResourceGroup -Name $ResourceGroupName -Location $Location | ||
|
||
# Create an App Service Plan | ||
New-AzureRMAppservicePlan -Name AppServiceManualScalePlan -ResourceGroupName $ResourceGroupName -Location $Location -Tier Basic | ||
|
||
# Create a Web App in the App Service Plan | ||
New-AzureRMWebApp -Name $AppName -ResourceGroupName $ResourceGroup -Location $Location -AppServicePlan AppServiceManualScalePlan | ||
|
||
# Scale Web App to 2 Workers | ||
Set-AzureRMAppServicePlan -NumberofWorkers 2 -Name AppServiceManualScalePlan -ResourceGroupName $ResourceGroupName |