diff --git a/deploy/az/sf-mesh/deploy.ps1 b/deploy/az/sf-mesh/deploy.ps1 new file mode 100644 index 000000000..a0b617314 --- /dev/null +++ b/deploy/az/sf-mesh/deploy.ps1 @@ -0,0 +1,107 @@ +<# + .SYNOPSIS + Deploys a template to Azure + + .DESCRIPTION + Deploys an Azure Resource Manager template + + .PARAMETER subscriptionId + The subscription id where the template will be deployed. + + .PARAMETER resourceGroupName + The resource group where the template will be deployed. Can be the name of an existing or a new resource group. + + .PARAMETER resourceGroupLocation + Optional, a resource group location. If specified, will try to create a new resource group in this location. If not specified, assumes resource group is existing. + + .PARAMETER deploymentName + The deployment name. + + .PARAMETER templateFilePath + Optional, path to the template file. Defaults to template.json. + + .PARAMETER parametersFilePath + Optional, path to the parameters file. Defaults to parameters.json. If file is not found, will prompt for parameter values based on template. +#> + +param( + [Parameter(Mandatory=$True)] + [string] + $subscriptionId, + + [Parameter(Mandatory=$True)] + [string] + $resourceGroupName, + + [string] + $resourceGroupLocation, + + [Parameter(Mandatory=$True)] + [string] + $deploymentName, + + [string] + $templateFilePath = "mesh_rp.linux.json", + + [string] + $parametersFilePath = "parameters.json" +) + +<# +.SYNOPSIS + Registers RPs +#> +Function RegisterRP { + Param( + [string]$ResourceProviderNamespace + ) + + Write-Host "Registering resource provider '$ResourceProviderNamespace'"; + Register-AzureRmResourceProvider -ProviderNamespace $ResourceProviderNamespace; +} + +#****************************************************************************** +# Script body +# Execution begins here +#****************************************************************************** +$ErrorActionPreference = "Stop" + +# sign in +Write-Host "Logging in..."; +Login-AzureRmAccount; + +# select subscription +Write-Host "Selecting subscription '$subscriptionId'"; +Select-AzureRmSubscription -SubscriptionID $subscriptionId; + +# Register RPs +$resourceProviders = @(); +if($resourceProviders.length) { + Write-Host "Registering resource providers" + foreach($resourceProvider in $resourceProviders) { + RegisterRP($resourceProvider); + } +} + +#Create or check for existing resource group +$resourceGroup = Get-AzureRmResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinue +if(!$resourceGroup) +{ + Write-Host "Resource group '$resourceGroupName' does not exist. To create a new resource group, please enter a location."; + if(!$resourceGroupLocation) { + $resourceGroupLocation = Read-Host "resourceGroupLocation"; + } + Write-Host "Creating resource group '$resourceGroupName' in location '$resourceGroupLocation'"; + New-AzureRmResourceGroup -Name $resourceGroupName -Location $resourceGroupLocation +} +else{ + Write-Host "Using existing resource group '$resourceGroupName'"; +} + +# Start the deployment +Write-Host "Starting deployment..."; +if(Test-Path $parametersFilePath) { + New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath -TemplateParameterFile $parametersFilePath; +} else { + New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath; +} \ No newline at end of file diff --git a/deploy/az/sf-mesh/deploy.sh b/deploy/az/sf-mesh/deploy.sh new file mode 100644 index 000000000..c0857b4e4 --- /dev/null +++ b/deploy/az/sf-mesh/deploy.sh @@ -0,0 +1,122 @@ +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' + +# -e: immediately exit if any command has a non-zero exit status +# -o: prevents errors in a pipeline from being masked +# IFS new value is less likely to cause confusing bugs when looping arrays or arguments (e.g. $@) + +usage() { echo "Usage: $0 -i -g -n -l " 1>&2; exit 1; } + +declare subscriptionId="" +declare resourceGroupName="" +declare deploymentName="" +declare resourceGroupLocation="" + +# Initialize parameters specified from command line +while getopts ":i:g:n:l:" arg; do + case "${arg}" in + i) + subscriptionId=${OPTARG} + ;; + g) + resourceGroupName=${OPTARG} + ;; + n) + deploymentName=${OPTARG} + ;; + l) + resourceGroupLocation=${OPTARG} + ;; + esac +done +shift $((OPTIND-1)) + +#Prompt for parameters is some required parameters are missing +if [[ -z "$subscriptionId" ]]; then + echo "Your subscription ID can be looked up with the CLI using: az account show --out json " + echo "Enter your subscription ID:" + read subscriptionId + [[ "${subscriptionId:?}" ]] +fi + +if [[ -z "$resourceGroupName" ]]; then + echo "This script will look for an existing resource group, otherwise a new one will be created " + echo "You can create new resource groups with the CLI using: az group create " + echo "Enter a resource group name" + read resourceGroupName + [[ "${resourceGroupName:?}" ]] +fi + +if [[ -z "$deploymentName" ]]; then + echo "Enter a name for this deployment:" + read deploymentName +fi + +if [[ -z "$resourceGroupLocation" ]]; then + echo "If creating a *new* resource group, you need to set a location " + echo "You can lookup locations with the CLI using: az account list-locations " + + echo "Enter resource group location:" + read resourceGroupLocation +fi + +#templateFile Path - template file to be used +templateFilePath="mesh_rp.linux.json" + +if [ ! -f "$templateFilePath" ]; then + echo "$templateFilePath not found" + exit 1 +fi + +#parameter file path +parametersFilePath="parameters.json" + +if [ ! -f "$parametersFilePath" ]; then + echo "$parametersFilePath not found" + exit 1 +fi + +if [ -z "$subscriptionId" ] || [ -z "$resourceGroupName" ] || [ -z "$deploymentName" ]; then + echo "Either one of subscriptionId, resourceGroupName, deploymentName is empty" + usage +fi + +#login to azure using your credentials +az account show 1> /dev/null + +if [ $? != 0 ]; +then + az login +fi + +#set the default subscription id +az account set --subscription $subscriptionId + +set +e + +#Check for existing RG +az group show --name $resourceGroupName 1> /dev/null + +if [ $? != 0 ]; then + echo "Resource group with name" $resourceGroupName "could not be found. Creating new resource group.." + set -e + ( + set -x + az group create --name $resourceGroupName --location $resourceGroupLocation 1> /dev/null + ) + else + echo "Using existing resource group..." +fi + +#Start deployment +echo "Starting deployment..." +( + set -x + az group deployment create --name "$deploymentName" --resource-group "$resourceGroupName" --template-file "$templateFilePath" --parameters "@${parametersFilePath}" +) + +if [ $? == 0 ]; + then + echo "Template has been successfully deployed" +fi diff --git a/deploy/az/sf-mesh/deployer.rb b/deploy/az/sf-mesh/deployer.rb new file mode 100644 index 000000000..9ec8b102d --- /dev/null +++ b/deploy/az/sf-mesh/deployer.rb @@ -0,0 +1,71 @@ +require 'azure_mgmt_resources' + +class Deployer + + # Initialize the deployer class with subscription, resource group and resource group location. The class will raise an + # ArgumentError if there are empty values for Tenant Id, Client Id or Client Secret environment variables. + # + # @param [String] subscription_id the subscription to deploy the template + # @param [String] resource_group the resource group to create or update and then deploy the template + # @param [String] resource_group_location the location of the resource group + def initialize(subscription_id, resource_group, resource_group_location) + raise ArgumentError.new("Missing template file 'template.json' in current directory.") unless File.exist?('mesh_rp.linux.json') + raise ArgumentError.new("Missing parameters file 'parameters.json' in current directory.") unless File.exist?('parameters.json') + @resource_group = resource_group + @subscription_id = subscription_id + @resource_group_location = resource_group_location + provider = MsRestAzure::ApplicationTokenProvider.new( + ENV['AZURE_TENANT_ID'], + ENV['AZURE_CLIENT_ID'], + ENV['AZURE_CLIENT_SECRET']) + credentials = MsRest::TokenCredentials.new(provider) + @client = Azure::ARM::Resources::ResourceManagementClient.new(credentials) + @client.subscription_id = @subscription_id + end + + # Deploy the template to a resource group + def deploy + # ensure the resource group is created + params = Azure::ARM::Resources::Models::ResourceGroup.new.tap do |rg| + rg.location = @resource_group_location + end + @client.resource_groups.create_or_update(@resource_group, params).value! + + # build the deployment from a json file template from parameters + template = File.read(File.expand_path(File.join(__dir__, 'mesh_rp.linux.json'))) + deployment = Azure::ARM::Resources::Models::Deployment.new + deployment.properties = Azure::ARM::Resources::Models::DeploymentProperties.new + deployment.properties.template = JSON.parse(template) + deployment.properties.mode = Azure::ARM::Resources::Models::DeploymentMode::Incremental + + # build the deployment template parameters from Hash to {key: {value: value}} format + deploy_params = File.read(File.expand_path(File.join(__dir__, 'parameters.json'))) + deployment.properties.parameters = JSON.parse(deploy_params)["parameters"] + + # put the deployment to the resource group + @client.deployments.create_or_update(@resource_group, 'azure-sample', deployment) + end +end + +# Get user inputs and execute the script +if(ARGV.empty?) + puts "Please specify subscriptionId resourceGroupName resourceGroupLocation as command line arguments" + exit +end + +subscription_id = ARGV[0] # Azure Subscription Id +resource_group = ARGV[1] # The resource group for deployment +resource_group_location = ARGV[2] # The resource group location + +msg = "\nInitializing the Deployer class with subscription id: #{subscription_id}, resource group: #{resource_group}" +msg += "\nand resource group location: #{resource_group_location}...\n\n" +puts msg + +# Initialize the deployer class +deployer = Deployer.new(subscription_id, resource_group, resource_group_location) + +puts "Beginning the deployment... \n\n" +# Deploy the template +deployment = deployer.deploy + +puts "Done deploying!!" \ No newline at end of file diff --git a/deploy/az/sf-mesh/mesh_rp.linux.json b/deploy/az/sf-mesh/mesh_rp.linux.json new file mode 100644 index 000000000..c5da8879a --- /dev/null +++ b/deploy/az/sf-mesh/mesh_rp.linux.json @@ -0,0 +1,781 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", + "contentVersion": "1.0.0.0", + "parameters": { + "location": { + "type": "string", + "metadata": { + "description": "Location of the resources." + }, + "defaultValue": "eastus" + } + }, + "resources": [ + { + "apiVersion": "2018-07-01-preview", + "name": "eShopNetwork", + "type": "Microsoft.ServiceFabricMesh/networks", + "location": "[parameters('location')]", + "dependsOn": [], + "properties": { + "addressPrefix": "10.0.0.4/22", + "ingressConfig": { + "layer4": [ + { + "name": "catalogapiIngress", + "publicPort": "5001", + "applicationName": "eShopOnMesh", + "serviceName": "catalogapi-svc", + "endpointName": "catalogListener" + }, + { + "name": "basketapiIngress", + "publicPort": "5002", + "applicationName": "eShopOnMesh", + "serviceName": "basketapi-svc", + "endpointName": "basketListener" + }, + { + "name": "orderingapiIngress", + "publicPort": "5004", + "applicationName": "eShopOnMesh", + "serviceName": "orderingapi-svc", + "endpointName": "orderingListener" + }, + { + "name": "marketingapiIngress", + "publicPort": "5005", + "applicationName": "eShopOnMesh", + "serviceName": "marketingapi-svc", + "endpointName": "marketingListener" + }, + { + "name": "locationsapiIngress", + "publicPort": "5007", + "applicationName": "eShopOnMesh", + "serviceName": "locationsapi-svc", + "endpointName": "locationsListener" + } + ] + } + } + }, + { + "apiVersion": "2018-07-01-preview", + "name": "eShopOnMesh", + "type": "Microsoft.ServiceFabricMesh/applications", + "location": "[parameters('location')]", + "dependsOn": [ + "Microsoft.ServiceFabricMesh/networks/eShopNetwork" + ], + "properties": { + "description": "eShopOnContainers on mesh", + "services": [ + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "sqldata-svc", + "properties": { + "description": "SQL Server (sql-data svc)", + "osType": "linux", + "codePackages": [ + { + "name": "sqldata", + "image": "microsoft/mssql-server-linux:latest", + "endpoints": [ + { + "name": "sqldataListener", + "port": "1433" + } + ], + "environmentVariables": [ + { + "name": "ACCEPT_EULA", + "value": "Y" + }, + { + "name": "SA_PASSWORD", + "value": "Pass@word" + } + ], + "resources": { + "requests": { + "cpu": "1", + "memoryInGB": "4" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "rabbitmq-svc", + "properties": { + "description": "rabbitmq", + "osType": "linux", + "codePackages": [ + { + "name": "rabbitmq", + "image": "rabbitmq:3-management-alpine", + "endpoints": [ + { + "name": "rabbitmqListener", + "port": "5672" + }, + { + "name": "rabbitManagementListener", + "port": "15672" + } + ], + "environmentVariables": [ + { + "name": "ACCEPT_EULA", + "value": "Y" + }, + { + "name": "SA_PASSWORD", + "value": "Pass@word" + } + ], + "resources": { + "requests": { + "cpu": "1", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "mongo-svc", + "properties": { + "description": "mongo", + "osType": "linux", + "codePackages": [ + { + "name": "mongo", + "image": "mongo:3.4.17", + "endpoints": [ + { + "name": "mongoListener", + "port": "27017" + } + ], + "resources": { + "requests": { + "cpu": "1", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "identityapi-svc", + "properties": { + "description": "Identity API Service.", + "osType": "linux", + "codePackages": [ + { + "name": "identity-api", + "image": "eshop/identity.api:dev", + "endpoints": [ + { + "name": "identityListener", + "port": "80" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:80" + }, + { + "name": "ConnectionString", + "value": "Server=sqldata-svc;Database=Microsoft.eShopOnContainers.Services.IdentityDb;User Id=sa;Password=Pass@word" + }, + { + "name": "SpaClient", + "value": "http://0.0.0.0:5104" + }, + { + "name": "XamarinCallback", + "value": "http://0.0.0.0:5105/xamarincallback" + }, + { + "name": "MvcClient", + "value": "http://0.0.0.0:5100" + }, + { + "name": "LocationApiClient", + "value": "http://0.0.0.0:5109" + }, + { + "name": "MarketingApiClient", + "value": "http://0.0.0.0:5110" + }, + { + "name": "BasketApiClient", + "value": "http://0.0.0.0:5103" + }, + { + "name": "OrderingApiClient", + "value": "http://0.0.0.0:5102" + }, + { + "name": "MobileShoppingAggClient", + "value": "http://0.0.0.0:5120" + }, + { + "name": "WebShoppingAggClient", + "value": "http://0.0.0.0:5121" + }, + { + "name": "UseCustomizationData", + "value": "True" + }, + { + "name": "OrchestratorType", + "value": "SF" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "catalogapi-svc", + "properties": { + "description": "Catalog API Service.", + "osType": "linux", + "codePackages": [ + { + "name": "catalog-api", + "image": "eshop/catalog.api:dev", + "endpoints": [ + { + "name": "catalogListener", + "port": "81" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:81" + }, + { + "name": "ConnectionString", + "value": "Server=sqldata-svc;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word" + }, + { + "name": "PicBaseUrl", + "value": "http://0.0.0.0:5202/api/v1/c/catalog/items/[0]/pic/" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureStorageEnabled", + "value": "False" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "basketapi-svc", + "properties": { + "description": "Basket API Service.", + "osType": "linux", + "codePackages": [ + { + "name": "basket-api", + "image": "eshop/basket.api:dev", + "endpoints": [ + { + "name": "basketListener", + "port": "82" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:82" + }, + { + "name": "ConnectionString", + "value": "Server=sqldata-svc;Database=Microsoft.eShopOnContainers.Services.BasketDb;User Id=sa;Password=Pass@word" + }, + { + "name": "identityUrl", + "value": "http://identity.api" + }, + { + "name": "IdentityUrlExternal", + "value": "http://10.121.122.162:5105" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureStorageEnabled", + "value": "False" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "orderingapi-svc", + "properties": { + "description": "Ordering API Service.", + "osType": "linux", + "codePackages": [ + { + "name": "ordering-api", + "image": "eshop/ordering.api:dev", + "endpoints": [ + { + "name": "orderingListener", + "port": "83" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:83" + }, + { + "name": "ConnectionString", + "value": "Server=sqldata-svc;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word" + }, + { + "name": "identityUrl", + "value": "http://identity.api" + }, + { + "name": "IdentityUrlExternal", + "value": "http://10.121.122.162:5105" + }, + { + "name": "CheckUpdateTime", + "value": "30000" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureStorageEnabled", + "value": "False" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "orderingbackgroundtasks-svc", + "properties": { + "description": "Ordering backgroundtasks API Service.", + "osType": "linux", + "codePackages": [ + { + "name": "ordering-backgroundtasks", + "image": "eshop/ordering.backgroundtasks:dev", + "endpoints": [ + { + "name": "orderingbackgroundtasksListener", + "port": "84" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:84" + }, + { + "name": "ConnectionString", + "value": "Server=sqldata-svc;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word" + }, + { + "name": "CheckUpdateTime", + "value": "30000" + }, + { + "name": "GracePeriodTime", + "value": "1" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureStorageEnabled", + "value": "False" + }, + { + "name": "UseCustomizationData", + "value": "True" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + }, + { + "name": "OrchestratorType", + "value": "SF" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "marketingapi-svc", + "properties": { + "description": "Marketing API Service.", + "osType": "linux", + "codePackages": [ + { + "name": "marketing-api", + "image": "eshop/marketing.api:dev", + "endpoints": [ + { + "name": "marketingListener", + "port": "85" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:85" + }, + { + "name": "ConnectionString", + "value": "Server=sqldata-svc;Database=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word" + }, + { + "name": "MongoConnectionString", + "value": "mongo-svc" + }, + { + "name": "MongoDatabase", + "value": "MarketingDb" + }, + { + "name": "PicBaseUrl", + "value": "http://0.0.0.0:5110/api/v1/campaigns/[0]/pic/" + }, + { + "name": "identityUrl", + "value": "http://identity.api" + }, + { + "name": "IdentityUrlExternal", + "value": "http://10.121.122.162:5105" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureStorageEnabled", + "value": "False" + }, + { + "name": "UseCustomizationData", + "value": "True" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + }, + { + "name": "OrchestratorType", + "value": "SF" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "paymentapi-svc", + "properties": { + "description": "Payment API Service.", + "osType": "linux", + "codePackages": [ + { + "name": "payment-api", + "image": "eshop/payment.api:dev", + "endpoints": [ + { + "name": "paymentListener", + "port": "86" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:86" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + }, + { + "name": "OrchestratorType", + "value": "SF" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "locationsapi-svc", + "properties": { + "description": "Locations API Service.", + "osType": "linux", + "codePackages": [ + { + "name": "locations-api", + "image": "eshop/locations.api:dev", + "endpoints": [ + { + "name": "locationsListener", + "port": "87" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:87" + }, + { + "name": "ConnectionString", + "value": "mongo-svc" + }, + { + "name": "Database", + "value": "LocationsDb" + }, + { + "name": "identityUrl", + "value": "http://identity.api" + }, + { + "name": "IdentityUrlExternal", + "value": "http://10.121.122.162:5105" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + }, + { + "name": "OrchestratorType", + "value": "SF" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + } + ] + } + } + ] + } \ No newline at end of file diff --git a/deploy/az/sf-mesh/mesh_rp.windows.json b/deploy/az/sf-mesh/mesh_rp.windows.json new file mode 100644 index 000000000..a5754a5d5 --- /dev/null +++ b/deploy/az/sf-mesh/mesh_rp.windows.json @@ -0,0 +1,781 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", + "contentVersion": "1.0.0.0", + "parameters": { + "location": { + "type": "string", + "metadata": { + "description": "Location of the resources." + }, + "defaultValue": "eastus" + } + }, + "resources": [ + { + "apiVersion": "2018-07-01-preview", + "name": "eShopNetwork", + "type": "Microsoft.ServiceFabricMesh/networks", + "location": "[parameters('location')]", + "dependsOn": [], + "properties": { + "addressPrefix": "10.0.0.4/22", + "ingressConfig": { + "layer4": [ + { + "name": "catalogapiIngress", + "publicPort": "5001", + "applicationName": "eShopOnMesh", + "serviceName": "catalogapi-svc", + "endpointName": "catalogListener" + }, + { + "name": "basketapiIngress", + "publicPort": "5002", + "applicationName": "eShopOnMesh", + "serviceName": "basketapi-svc", + "endpointName": "basketListener" + }, + { + "name": "orderingapiIngress", + "publicPort": "5004", + "applicationName": "eShopOnMesh", + "serviceName": "orderingapi-svc", + "endpointName": "orderingListener" + }, + { + "name": "marketingapiIngress", + "publicPort": "5005", + "applicationName": "eShopOnMesh", + "serviceName": "marketingapi-svc", + "endpointName": "marketingListener" + }, + { + "name": "locationsapiIngress", + "publicPort": "5007", + "applicationName": "eShopOnMesh", + "serviceName": "locationsapi-svc", + "endpointName": "locationsListener" + } + ] + } + } + }, + { + "apiVersion": "2018-07-01-preview", + "name": "eShopOnMesh", + "type": "Microsoft.ServiceFabricMesh/applications", + "location": "[parameters('location')]", + "dependsOn": [ + "Microsoft.ServiceFabricMesh/networks/eShopNetwork" + ], + "properties": { + "description": "eShopOnContainers on mesh", + "services": [ + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "sqldata-svc", + "properties": { + "description": "SQL Server (sql-data svc)", + "osType": "windows", + "codePackages": [ + { + "name": "sqldata", + "image": "microsoft/mssql-server-windows:latest", + "endpoints": [ + { + "name": "sqldataListener", + "port": "1433" + } + ], + "environmentVariables": [ + { + "name": "ACCEPT_EULA", + "value": "Y" + }, + { + "name": "SA_PASSWORD", + "value": "Pass@word" + } + ], + "resources": { + "requests": { + "cpu": "1", + "memoryInGB": "4" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "rabbitmq-svc", + "properties": { + "description": "rabbitmq", + "osType": "windows", + "codePackages": [ + { + "name": "rabbitmq", + "image": "rabbitmq:3-management-alpine", + "endpoints": [ + { + "name": "rabbitmqListener", + "port": "5672" + }, + { + "name": "rabbitManagementListener", + "port": "15672" + } + ], + "environmentVariables": [ + { + "name": "ACCEPT_EULA", + "value": "Y" + }, + { + "name": "SA_PASSWORD", + "value": "Pass@word" + } + ], + "resources": { + "requests": { + "cpu": "1", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "mongo-svc", + "properties": { + "description": "mongo", + "osType": "windows", + "codePackages": [ + { + "name": "mongo", + "image": "mongo:3.4.17", + "endpoints": [ + { + "name": "mongoListener", + "port": "27017" + } + ], + "resources": { + "requests": { + "cpu": "1", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "identityapi-svc", + "properties": { + "description": "Identity API Service.", + "osType": "windows", + "codePackages": [ + { + "name": "identity-api", + "image": "eshop/identity.api:dev", + "endpoints": [ + { + "name": "identityListener", + "port": "80" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:80" + }, + { + "name": "ConnectionString", + "value": "Server=sqldata-svc;Database=Microsoft.eShopOnContainers.Services.IdentityDb;User Id=sa;Password=Pass@word" + }, + { + "name": "SpaClient", + "value": "http://0.0.0.0:5104" + }, + { + "name": "XamarinCallback", + "value": "http://0.0.0.0:5105/xamarincallback" + }, + { + "name": "MvcClient", + "value": "http://0.0.0.0:5100" + }, + { + "name": "LocationApiClient", + "value": "http://0.0.0.0:5109" + }, + { + "name": "MarketingApiClient", + "value": "http://0.0.0.0:5110" + }, + { + "name": "BasketApiClient", + "value": "http://0.0.0.0:5103" + }, + { + "name": "OrderingApiClient", + "value": "http://0.0.0.0:5102" + }, + { + "name": "MobileShoppingAggClient", + "value": "http://0.0.0.0:5120" + }, + { + "name": "WebShoppingAggClient", + "value": "http://0.0.0.0:5121" + }, + { + "name": "UseCustomizationData", + "value": "True" + }, + { + "name": "OrchestratorType", + "value": "SF" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "catalogapi-svc", + "properties": { + "description": "Catalog API Service.", + "osType": "windows", + "codePackages": [ + { + "name": "catalog-api", + "image": "eshop/catalog.api:dev", + "endpoints": [ + { + "name": "catalogListener", + "port": "81" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:81" + }, + { + "name": "ConnectionString", + "value": "Server=sqldata-svc;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word" + }, + { + "name": "PicBaseUrl", + "value": "http://0.0.0.0:5202/api/v1/c/catalog/items/[0]/pic/" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureStorageEnabled", + "value": "False" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "basketapi-svc", + "properties": { + "description": "Basket API Service.", + "osType": "windows", + "codePackages": [ + { + "name": "basket-api", + "image": "eshop/basket.api:dev", + "endpoints": [ + { + "name": "basketListener", + "port": "82" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:82" + }, + { + "name": "ConnectionString", + "value": "Server=sqldata-svc;Database=Microsoft.eShopOnContainers.Services.BasketDb;User Id=sa;Password=Pass@word" + }, + { + "name": "identityUrl", + "value": "http://identity.api" + }, + { + "name": "IdentityUrlExternal", + "value": "http://10.121.122.162:5105" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureStorageEnabled", + "value": "False" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "orderingapi-svc", + "properties": { + "description": "Ordering API Service.", + "osType": "windows", + "codePackages": [ + { + "name": "ordering-api", + "image": "eshop/ordering.api:dev", + "endpoints": [ + { + "name": "orderingListener", + "port": "83" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:83" + }, + { + "name": "ConnectionString", + "value": "Server=sqldata-svc;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word" + }, + { + "name": "identityUrl", + "value": "http://identity.api" + }, + { + "name": "IdentityUrlExternal", + "value": "http://10.121.122.162:5105" + }, + { + "name": "CheckUpdateTime", + "value": "30000" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureStorageEnabled", + "value": "False" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "orderingbackgroundtasks-svc", + "properties": { + "description": "Ordering backgroundtasks API Service.", + "osType": "windows", + "codePackages": [ + { + "name": "ordering-backgroundtasks", + "image": "eshop/ordering.backgroundtasks:dev", + "endpoints": [ + { + "name": "orderingbackgroundtasksListener", + "port": "84" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:84" + }, + { + "name": "ConnectionString", + "value": "Server=sqldata-svc;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word" + }, + { + "name": "CheckUpdateTime", + "value": "30000" + }, + { + "name": "GracePeriodTime", + "value": "1" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureStorageEnabled", + "value": "False" + }, + { + "name": "UseCustomizationData", + "value": "True" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + }, + { + "name": "OrchestratorType", + "value": "SF" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "marketingapi-svc", + "properties": { + "description": "Marketing API Service.", + "osType": "windows", + "codePackages": [ + { + "name": "marketing-api", + "image": "eshop/marketing.api:dev", + "endpoints": [ + { + "name": "marketingListener", + "port": "85" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:85" + }, + { + "name": "ConnectionString", + "value": "Server=sqldata-svc;Database=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word" + }, + { + "name": "MongoConnectionString", + "value": "mongo-svc" + }, + { + "name": "MongoDatabase", + "value": "MarketingDb" + }, + { + "name": "PicBaseUrl", + "value": "http://0.0.0.0:5110/api/v1/campaigns/[0]/pic/" + }, + { + "name": "identityUrl", + "value": "http://identity.api" + }, + { + "name": "IdentityUrlExternal", + "value": "http://10.121.122.162:5105" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureStorageEnabled", + "value": "False" + }, + { + "name": "UseCustomizationData", + "value": "True" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + }, + { + "name": "OrchestratorType", + "value": "SF" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "paymentapi-svc", + "properties": { + "description": "Payment API Service.", + "osType": "windows", + "codePackages": [ + { + "name": "payment-api", + "image": "eshop/payment.api:dev", + "endpoints": [ + { + "name": "paymentListener", + "port": "86" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:86" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + }, + { + "name": "OrchestratorType", + "value": "SF" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + }, + { + "type": "Microsoft.ServiceFabricMesh/services", + "location": "[parameters('location')]", + "name": "locationsapi-svc", + "properties": { + "description": "Locations API Service.", + "osType": "windows", + "codePackages": [ + { + "name": "locations-api", + "image": "eshop/locations.api:dev", + "endpoints": [ + { + "name": "locationsListener", + "port": "87" + } + ], + "environmentVariables": [ + { + "name": "ASPNETCORE_ENVIRONMENT", + "value": "Development" + }, + { + "name": "ASPNETCORE_URLS", + "value": "http://0.0.0.0:87" + }, + { + "name": "ConnectionString", + "value": "mongo-svc" + }, + { + "name": "Database", + "value": "LocationsDb" + }, + { + "name": "identityUrl", + "value": "http://identity.api" + }, + { + "name": "IdentityUrlExternal", + "value": "http://10.121.122.162:5105" + }, + { + "name": "EventBusConnection", + "value": "rabbitmq-svc" + }, + { + "name": "AzureServiceBusEnabled", + "value": "False" + }, + { + "name": "OrchestratorType", + "value": "SF" + } + ], + "resources": { + "requests": { + "cpu": "0.5", + "memoryInGB": "1" + } + } + } + ], + "replicaCount": "1", + "networkRefs": [ + { + "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'eShopNetwork')]" + } + ] + } + } + ] + } + } + ] + } \ No newline at end of file diff --git a/deploy/az/sf-mesh/parameters.json b/deploy/az/sf-mesh/parameters.json new file mode 100644 index 000000000..759a26884 --- /dev/null +++ b/deploy/az/sf-mesh/parameters.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "location": { + "value": "eastus" + } + } +} \ No newline at end of file diff --git a/deploy/az/sf-mesh/readme.md b/deploy/az/sf-mesh/readme.md new file mode 100644 index 000000000..32a50b71b --- /dev/null +++ b/deploy/az/sf-mesh/readme.md @@ -0,0 +1,23 @@ +#Install mesh extension + az extension add --name mesh + +#Desploy command + az mesh deployment create --resource-group {{resource-group}} --template-file {{path-file}} --parameters {{parameters}} + + Examples: + - [resource-group] test + - [path-file] C:/Users/epique/Desktop/mesh_rp.linux.json + - [parameters] "{'location': {'value': 'eastus'}}" + +#Logs command + az mesh code-package-log get --app-name {{app-name}} --code-package-name {{code-package-name}} -g {{resource-group}} --service-name {{service-name}} --replica-name {{replica-name}} + + Examples: + - [app-name] eShopOnMesh + - [code-package-name] catalog-api + - [resource-group] test + - [service-name] catalogapi-svc + - [replica-name] 0 (is numeric, start into 0) + +#Show service command + az mesh service show --app-name {{app-name}} -g {{resource-group}} -n {{service-name}} \ No newline at end of file