diff --git a/deploy/arm/eShopOnAzure.Deploy.sln b/deploy/arm/eShopOnAzure.Deploy.sln deleted file mode 100644 index 6fb65821a..000000000 --- a/deploy/arm/eShopOnAzure.Deploy.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.6 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{151D2E53-A2C4-4D7D-83FE-D05416EBD58E}") = "eShopOnAzure.Deploy", "eShopOnAzure.Deploy\eShopOnAzure.Deploy.deployproj", "{642B3F2E-3011-4B1A-8D22-D35C11C44F05}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {642B3F2E-3011-4B1A-8D22-D35C11C44F05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {642B3F2E-3011-4B1A-8D22-D35C11C44F05}.Debug|Any CPU.Build.0 = Debug|Any CPU - {642B3F2E-3011-4B1A-8D22-D35C11C44F05}.Release|Any CPU.ActiveCfg = Release|Any CPU - {642B3F2E-3011-4B1A-8D22-D35C11C44F05}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/deploy/arm/eShopOnAzure.Deploy/Deploy-AzureResourceGroup.ps1 b/deploy/arm/eShopOnAzure.Deploy/Deploy-AzureResourceGroup.ps1 deleted file mode 100644 index cf119eea6..000000000 --- a/deploy/arm/eShopOnAzure.Deploy/Deploy-AzureResourceGroup.ps1 +++ /dev/null @@ -1,120 +0,0 @@ -#Requires -Version 3.0 -#Requires -Module AzureRM.Resources -#Requires -Module Azure.Storage - -Param( - [string] [Parameter(Mandatory=$true)] $ResourceGroupLocation, - [string] $ResourceGroupName = 'eShopOnAzure.Deploy', - [switch] $UploadArtifacts, - [string] $StorageAccountName, - [string] $StorageContainerName = $ResourceGroupName.ToLowerInvariant() + '-stageartifacts', - [string] $TemplateFile = 'azuredeploy.json', - [string] $TemplateParametersFile = 'azuredeploy.parameters.json', - [string] $ArtifactStagingDirectory = '.', - [string] $DSCSourceFolder = 'DSC', - [switch] $ValidateOnly -) - -try { - [Microsoft.Azure.Common.Authentication.AzureSession]::ClientFactory.AddUserAgent("VSAzureTools-$UI$($host.name)".replace(' ','_'), '3.0.0') -} catch { } - -$ErrorActionPreference = 'Stop' -Set-StrictMode -Version 3 - -function Format-ValidationOutput { - param ($ValidationOutput, [int] $Depth = 0) - Set-StrictMode -Off - return @($ValidationOutput | Where-Object { $_ -ne $null } | ForEach-Object { @(' ' * $Depth + ': ' + $_.Message) + @(Format-ValidationOutput @($_.Details) ($Depth + 1)) }) -} - -$OptionalParameters = New-Object -TypeName Hashtable -$TemplateFile = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $TemplateFile)) -$TemplateParametersFile = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $TemplateParametersFile)) - -if ($UploadArtifacts) { - # Convert relative paths to absolute paths if needed - $ArtifactStagingDirectory = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $ArtifactStagingDirectory)) - $DSCSourceFolder = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $DSCSourceFolder)) - - # Parse the parameter file and update the values of artifacts location and artifacts location SAS token if they are present - $JsonParameters = Get-Content $TemplateParametersFile -Raw | ConvertFrom-Json - if (($JsonParameters | Get-Member -Type NoteProperty 'parameters') -ne $null) { - $JsonParameters = $JsonParameters.parameters - } - $ArtifactsLocationName = '_artifactsLocation' - $ArtifactsLocationSasTokenName = '_artifactsLocationSasToken' - $OptionalParameters[$ArtifactsLocationName] = $JsonParameters | Select -Expand $ArtifactsLocationName -ErrorAction Ignore | Select -Expand 'value' -ErrorAction Ignore - $OptionalParameters[$ArtifactsLocationSasTokenName] = $JsonParameters | Select -Expand $ArtifactsLocationSasTokenName -ErrorAction Ignore | Select -Expand 'value' -ErrorAction Ignore - - # Create DSC configuration archive - if (Test-Path $DSCSourceFolder) { - $DSCSourceFilePaths = @(Get-ChildItem $DSCSourceFolder -File -Filter '*.ps1' | ForEach-Object -Process {$_.FullName}) - foreach ($DSCSourceFilePath in $DSCSourceFilePaths) { - $DSCArchiveFilePath = $DSCSourceFilePath.Substring(0, $DSCSourceFilePath.Length - 4) + '.zip' - Publish-AzureRmVMDscConfiguration $DSCSourceFilePath -OutputArchivePath $DSCArchiveFilePath -Force -Verbose - } - } - - # Create a storage account name if none was provided - if ($StorageAccountName -eq '') { - $StorageAccountName = 'stage' + ((Get-AzureRmContext).Subscription.SubscriptionId).Replace('-', '').substring(0, 19) - } - - $StorageAccount = (Get-AzureRmStorageAccount | Where-Object{$_.StorageAccountName -eq $StorageAccountName}) - - # Create the storage account if it doesn't already exist - if ($StorageAccount -eq $null) { - $StorageResourceGroupName = 'ARM_Deploy_Staging' - New-AzureRmResourceGroup -Location "$ResourceGroupLocation" -Name $StorageResourceGroupName -Force - $StorageAccount = New-AzureRmStorageAccount -StorageAccountName $StorageAccountName -Type 'Standard_LRS' -ResourceGroupName $StorageResourceGroupName -Location "$ResourceGroupLocation" - } - - # Generate the value for artifacts location if it is not provided in the parameter file - if ($OptionalParameters[$ArtifactsLocationName] -eq $null) { - $OptionalParameters[$ArtifactsLocationName] = $StorageAccount.Context.BlobEndPoint + $StorageContainerName - } - - # Copy files from the local storage staging location to the storage account container - New-AzureStorageContainer -Name $StorageContainerName -Context $StorageAccount.Context -ErrorAction SilentlyContinue *>&1 - - $ArtifactFilePaths = Get-ChildItem $ArtifactStagingDirectory -Recurse -File | ForEach-Object -Process {$_.FullName} - foreach ($SourcePath in $ArtifactFilePaths) { - Set-AzureStorageBlobContent -File $SourcePath -Blob $SourcePath.Substring($ArtifactStagingDirectory.length + 1) ` - -Container $StorageContainerName -Context $StorageAccount.Context -Force - } - - # Generate a 4 hour SAS token for the artifacts location if one was not provided in the parameters file - if ($OptionalParameters[$ArtifactsLocationSasTokenName] -eq $null) { - $OptionalParameters[$ArtifactsLocationSasTokenName] = ConvertTo-SecureString -AsPlainText -Force ` - (New-AzureStorageContainerSASToken -Container $StorageContainerName -Context $StorageAccount.Context -Permission r -ExpiryTime (Get-Date).AddHours(4)) - } -} - -# Create or update the resource group using the specified template file and template parameters file -New-AzureRmResourceGroup -Name $ResourceGroupName -Location $ResourceGroupLocation -Verbose -Force - -if ($ValidateOnly) { - $ErrorMessages = Format-ValidationOutput (Test-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroupName ` - -TemplateFile $TemplateFile ` - -TemplateParameterFile $TemplateParametersFile ` - @OptionalParameters) - if ($ErrorMessages) { - Write-Output '', 'Validation returned the following errors:', @($ErrorMessages), '', 'Template is invalid.' - } - else { - Write-Output '', 'Template is valid.' - } -} -else { - New-AzureRmResourceGroupDeployment -Name ((Get-ChildItem $TemplateFile).BaseName + '-' + ((Get-Date).ToUniversalTime()).ToString('MMdd-HHmm')) ` - -ResourceGroupName $ResourceGroupName ` - -TemplateFile $TemplateFile ` - -TemplateParameterFile $TemplateParametersFile ` - @OptionalParameters ` - -Force -Verbose ` - -ErrorVariable ErrorMessages - if ($ErrorMessages) { - Write-Output '', 'Template deployment returned the following errors:', @(@($ErrorMessages) | ForEach-Object { $_.Exception.Message.TrimEnd("`r`n") }) - } -} \ No newline at end of file diff --git a/deploy/arm/eShopOnAzure.Deploy/Deployment.targets b/deploy/arm/eShopOnAzure.Deploy/Deployment.targets deleted file mode 100644 index 0d792ec66..000000000 --- a/deploy/arm/eShopOnAzure.Deploy/Deployment.targets +++ /dev/null @@ -1,123 +0,0 @@ - - - - Debug - AnyCPU - bin\$(Configuration)\ - false - true - false - None - obj\ - $(BaseIntermediateOutputPath)\ - $(BaseIntermediateOutputPath)$(Configuration)\ - $(IntermediateOutputPath)ProjectReferences - $(ProjectReferencesOutputPath)\ - true - - - - false - false - - - - - - - - - - - Always - - - Never - - - false - Build - - - - - - - - _GetDeploymentProjectContent; - _CalculateContentOutputRelativePaths; - _GetReferencedProjectsOutput; - _CalculateArtifactStagingDirectory; - _CopyOutputToArtifactStagingDirectory; - - - - - - - - - - - - - - - - - Configuration=$(Configuration);Platform=$(Platform) - - - - - - - $([System.IO.Path]::GetFileNameWithoutExtension('%(ProjectReference.Identity)')) - - - - - - - $(OutDir) - $(OutputPath) - $(ArtifactStagingDirectory)\ - $(ArtifactStagingDirectory)staging\ - $(Build_StagingDirectory) - - - - - - - <_OriginalIdentity>%(DeploymentProjectContentOutput.Identity) - <_RelativePath>$(_OriginalIdentity.Replace('$(MSBuildProjectDirectory)', '')) - - - - - $(_RelativePath) - - - - - - - - - PrepareForRun - - - - - - - - - - - diff --git a/deploy/arm/eShopOnAzure.Deploy/eShopOnAzure.Deploy.deployproj b/deploy/arm/eShopOnAzure.Deploy/eShopOnAzure.Deploy.deployproj deleted file mode 100644 index b44305d1e..000000000 --- a/deploy/arm/eShopOnAzure.Deploy/eShopOnAzure.Deploy.deployproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - - Debug - AnyCPU - - - Release - AnyCPU - - - - 642b3f2e-3011-4b1a-8d22-d35c11c44f05 - - - Deployment - 1.0 - - - - - - - - - - - False - - - - Never - - - - - \ No newline at end of file diff --git a/deploy/az/create-resources.cmd b/deploy/az/create-resources.cmd new file mode 100644 index 000000000..bd27efe3e --- /dev/null +++ b/deploy/az/create-resources.cmd @@ -0,0 +1,23 @@ +@echo off +if %1.==. GOTO error +if %2.==. GOTO error +if NOT %3.==-c. GOTO deployresources +if %4.==. GOTO error +echo Creating resource group %2 in '%4' +call az group create --name %2 --location %4 +:deployresources +echo Deploying ARM template '%1.json' in resource group %2 +call az group deployment create --resource-group %2 --parameters @%1.parameters.json --template-file %1.json +GOTO end +:error +echo. +echo Usage: +echo create-resources arm-file resource-group-name [-c location] +echo arm-file: Path to ARM template WITHOUT .json extension. An parameter file with same name plus '.parameters' MUST exist in same folde +echo resource-grop-name: Name of the resource group to use or create +echo -c: If appears means that resource group must be created. If -c is specified, must use enter location +echo. +echo Examples: +echo create-resources path_and_filename testgroup (Deploys path_and_filename.json with parameters specified in path_and_filename.parameters.json file). +echo create-resources path_and_filename newgroup -c westus (Deploys path_and_filename.json (with parameters specified in path_and_filename.parameters.json file) in a NEW resource group named newgroup in the westus location) +:end diff --git a/deploy/az/readme.md b/deploy/az/readme.md new file mode 100644 index 000000000..cee4581cb --- /dev/null +++ b/deploy/az/readme.md @@ -0,0 +1,20 @@ +# Deploying resources using create-resources script + +The `create-resources` script is a basic script to allow easy deployment of one ARM template in one resource group. You can deploy to an existing resource group or to create one. + +## Deploying to a existing resource group + +Just type `create-resources path-to-arm-template resourcegroup`. Called this way the script will: + +1. Search for `path-to-arm-template.json` and `path-to-arm-template.parameters.json` files +2. If they exist, will deploy them in the `resourcegroup` specified (that has to exist). + +## Deploying to a new resource group + +Just type `create-resources path-to-arm-template resourcegroup -c location`. Called this way the script will: + +1. Search for `path-to-arm-template.json` and `path-to-arm-template.parameters.json` files +2. If they exist, will create the `resourcegroup` specified in the `location` specified. +3. Finally will deploy `path-to-arm-template.json` and `path-to-arm-template.parameters.json` files in the `resourcegroup` + + diff --git a/deploy/az/sql/readme.md b/deploy/az/sql/readme.md new file mode 100644 index 000000000..bbc0b9140 --- /dev/null +++ b/deploy/az/sql/readme.md @@ -0,0 +1,33 @@ +# Deploying SQL Server & SQL Databases + +The ARM template `sqldeploy.json` and its parameter file (`sqldeploy.parameters.json`) are used to deploy following resources: + +1. One SQL Server +2. Three SQL databases (for ordering, catalog and identity) services. +3. Firewall rules to **allow access from any IP to SQL Server**. This allows easy management, but is not desired in production environments. + +## Editing sqldeploy.parameters.json file + +You have to edit the `sqldeploy.parameters.json` file to set your values. There are two parameters: + +1. `sql_server` is a object parameter that contains the sql server name, the admin login and password, and the database names. +2. `suffix` is a suffix that will be added to thee sql_server name to ensure uniqueness. + +## Deploy the template + +Once parameter file is edited you can deploy it using [create-resources script](../readme.md). + +i. e. if you are in windows, to deploy sql databases in a new resourcegroup located in westus, go to `deploy\az` folder and type: + +``` +create-resources.cmd sql\sqldeploy newResourceGroup -c westus +``` + + + + + + + + + diff --git a/deploy/arm/eShopOnAzure.Deploy/sqldeploy.json b/deploy/az/sql/sqldeploy.json similarity index 100% rename from deploy/arm/eShopOnAzure.Deploy/sqldeploy.json rename to deploy/az/sql/sqldeploy.json diff --git a/deploy/arm/eShopOnAzure.Deploy/sqldeploy.parameters.json b/deploy/az/sql/sqldeploy.parameters.json similarity index 100% rename from deploy/arm/eShopOnAzure.Deploy/sqldeploy.parameters.json rename to deploy/az/sql/sqldeploy.parameters.json diff --git a/deploy/az/vms/linux-vm/create-resources.cmd b/deploy/az/vms/linux-vm/create-resources.cmd deleted file mode 100644 index 82ac4da6d..000000000 --- a/deploy/az/vms/linux-vm/create-resources.cmd +++ /dev/null @@ -1,21 +0,0 @@ -@echo off -if %1.==. GOTO error -if NOT %2.==-c. GOTO createvm -if %3.==. GOTO error -echo Creating resource group %1 in '%3' -call az group create --name %1 --location %3 -:createvm -echo Creating VM in resource group %1 -call az group deployment create --resource-group %1 --parameters @mvparams.json --template-file azuredeploy.json -GOTO end -:error -echo. -echo Usage: -echo create-resources resource-group-name [-c location] -echo resource-grop-name: Name of the resource group to use or create -echo -c: If appears means that resource group must be created. If -c is specified, must use enter location -echo. -echo Examples: -echo create-resources testgroup (Creates VM in a existing testgroup resource group) -echo create-resources newgroup -c westus (Creates the VM in a NEW resource group named newgroup in the westus location) -:end diff --git a/deploy/az/vms/linux-vm/azuredeploy.json b/deploy/az/vms/linux-vm/linuxvm.json similarity index 100% rename from deploy/az/vms/linux-vm/azuredeploy.json rename to deploy/az/vms/linux-vm/linuxvm.json diff --git a/deploy/az/vms/linux-vm/mvparams.json b/deploy/az/vms/linux-vm/linuxvm.parameters.json similarity index 100% rename from deploy/az/vms/linux-vm/mvparams.json rename to deploy/az/vms/linux-vm/linuxvm.parameters.json diff --git a/deploy/az/vms/readme.md b/deploy/az/vms/readme.md index ad9993e53..28b528330 100644 --- a/deploy/az/vms/readme.md +++ b/deploy/az/vms/readme.md @@ -13,15 +13,21 @@ Ensure you are logged in the desired subscription (use `az login` and `az accoun Go to `linux-vm` or `win-vm` folder (based on if you want a Linux or Windows VM). Then: -1. Edit the file `mvparams.json` with your desired values -2. Run the file `create-resources.cmd` from command-line to create the VM. +1. Edit the file `linuxvm.parameters.json` or `windowsvm.parameters.json` (based on what VM do you want to create) with your desired values +2. Run the [create-resources script](../readme.md) to deploy the desired template (`linux-vm/linuxvm.json` or `win-vm/windowsvm.json`). -**Note:** To avoid errors, ARM template used (`azuredeploy.json`), generates unique names for: +I. e. if you are in Windows and want to deploy a linux based VM, in a new resourcegroup located in westus, go to `deploy\az` folder and type: + +``` +create-resources.cmd vms\linux-vm\linuxvm newResourceGroup -c westus +``` + +**Note:** To avoid errors, ARM template used generates unique names for: 1. VM used storage 2. Public DNS -Those public names are based on the parameters set in `mvparams.json` file. +Those public names are based on the parameters set in the parameters file. ### The mvparams.json file diff --git a/deploy/az/vms/win-vm/create-resources.cmd b/deploy/az/vms/win-vm/create-resources.cmd deleted file mode 100644 index 07ac2a2da..000000000 --- a/deploy/az/vms/win-vm/create-resources.cmd +++ /dev/null @@ -1,15 +0,0 @@ -if %1.==. GOTO error -if %2.!=-c. GOTO createvm -if %3.==. GOTO error -az group create --name %1 --location %3 -createvm: -az group deployment create --resource-group %1 --parameters @mvparams.json --template-file azuredeploy.json -GOTO end -error: -@echo Usage: create-resources [-c location] -@echo : Name of the resource group to use or create -@echo -c: If appears means that resource group must be created. If -c is specified, must use enter location -@echo Examples: -@echo create-resources testgroup (Creates VM in a existing testgroup resource group) -@echo create-resources newgroup -c westus (Creates the VM in a NEW resource group named newgroup in the westus location) -end: diff --git a/deploy/az/vms/win-vm/azuredeploy.json b/deploy/az/vms/win-vm/windowsvm.json similarity index 100% rename from deploy/az/vms/win-vm/azuredeploy.json rename to deploy/az/vms/win-vm/windowsvm.json diff --git a/deploy/az/vms/win-vm/mvparams.json b/deploy/az/vms/win-vm/windowsvm.parameters.json similarity index 100% rename from deploy/az/vms/win-vm/mvparams.json rename to deploy/az/vms/win-vm/windowsvm.parameters.json diff --git a/deploy/readme.md b/deploy/readme.md index 66efea64b..0a24fdaba 100644 --- a/deploy/readme.md +++ b/deploy/readme.md @@ -14,7 +14,7 @@ Login into your azure subscription by typing `az login` (note that you maybe nee ## Deploying Azure resources used by the services -1. [Deploying SQL Server and databases](arm/sql-server.md) +1. [Deploying SQL Server and databases](az/sql/readme.md)