add variables for new api sf

This commit is contained in:
Erik Pique 2019-01-07 10:16:30 +01:00
parent 69f0b4393d
commit be0b868d3b
12 changed files with 64 additions and 28 deletions

View File

@ -0,0 +1,9 @@
.dockerignore
.env
.git
.gitignore
.vs
.vscode
*/bin
*/obj
**/.toolstarget

View File

@ -6,6 +6,8 @@
<ServerGarbageCollection>True</ServerGarbageCollection>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<TargetLatestRuntimePatch>False</TargetLatestRuntimePatch>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<UserSecretsId>860c6d00-8a17-45b6-be76-28c2395d468e</UserSecretsId>
</PropertyGroup>
<ItemGroup>
@ -16,6 +18,7 @@
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.ServiceFabric.AspNetCore.Kestrel" Version="3.3.617" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.0.2105168" />
</ItemGroup>
</Project>

View File

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<!-- Add your custom configuration sections and parameters here -->
<!--
<Section Name="MyConfigSection">
<Parameter Name="MyParameter" Value="Value1" />
</Section>
-->
<!--<Section Name="ServiceFabricSettings">
<Parameter Name="UrlMobilMarketing" Value="configuration/mobile/marketing" />
<Parameter Name="UrlMobilShopping" Value="/configuration/mobile/shopping" />
<Parameter Name="UrlWebMarketing" Value="/configuration/web/marketing" />
<Parameter Name="UrlWebShopping" Value="/configuration/web/shopping" />
</Section>-->
</Settings>

View File

@ -17,9 +17,18 @@
<Program>ApiGw_Base.exe</Program>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
<!--<ContainerHost>
<ImageName>eshop/sf.linux.settings.api:#{tag}#</ImageName>
</ContainerHost>-->
</EntryPoint>
<EnvironmentVariables>
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value=""/>
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="Development"/>
<EnvironmentVariable Name="ASPNETCORE_URLS" Value="http://0.0.0.0:80"/>
<EnvironmentVariable Name="UrlMobilMarketing" Value="http://apigw_base.eshoponservicefabricapigwtype/configuration/mobile/marketing" />
<EnvironmentVariable Name="UrlMobilShopping" Value="http://apigw_base.eshoponservicefabricapigwtype/configuration/mobile/shopping" />
<EnvironmentVariable Name="UrlWebMarketing" Value="http://apigw_base.eshoponservicefabricapigwtype/configuration/web/marketing" />
<EnvironmentVariable Name="UrlWebShopping" Value="http://apigw_base.eshoponservicefabricapigwtype/configuration/web/shopping" />
<EnvironmentVariable Name="OrchestratorType" Value="SF"/>
</EnvironmentVariables>
</CodePackage>
@ -32,6 +41,7 @@
<!-- This endpoint is used by the communication listener to obtain the port on which to
listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. -->
<!--<Endpoint UriScheme="http" Name="sf.linux.settings.api.endpoint" Port="8912" />-->
<Endpoint Protocol="https" Name="ServiceEndpoint" Type="Input" Port="8912" />
</Endpoints>
</Resources>

View File

@ -1,5 +1,4 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
@ -8,6 +7,7 @@
"sslPort": 44363
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
@ -21,10 +21,15 @@
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/api/values"
}
}
}

View File

@ -13,6 +13,11 @@
<EnvironmentOverrides CodePackageRef="code">
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="[ApiGw_Base_ASPNETCORE_ENVIRONMENT]" />
</EnvironmentOverrides>
<!--<Policies>
<ContainerHostPolicies CodePackageRef="Code">
<PortBinding ContainerPort="80" EndpointRef="sf.linux.settings.api.endpoint" />
</ContainerHostPolicies>
</Policies>-->
</ServiceManifestImport>
<DefaultServices>
<!-- The section below creates instances of service types, when an instance of this
@ -20,7 +25,7 @@
ServiceFabric PowerShell module.
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. -->
<Service Name="ApiGw_Base" ServicePackageActivationMode="ExclusiveProcess">
<Service Name="ApiGw_Base" ServiceDnsName="apigw_base.eshoponservicefabricapigwtype" ServicePackageActivationMode="ExclusiveProcess">
<StatelessService ServiceTypeName="ApiGw_BaseType" InstanceCount="[ApiGw_Base_InstanceCount]">
<SingletonPartition />
</StatelessService>

View File

@ -314,4 +314,3 @@ services:
- UseLoadTest=${USE_LOADTEST:-False}
ports:
- "5100:80"

View File

@ -304,4 +304,3 @@ services:
ports:
- "80" # Important: In a production environment your should remove the external port (5121) kept here for microservice debugging purposes.
# The API Gateway redirects and access through the internal port (80).

View File

@ -216,4 +216,3 @@ services:
- webshoppingagg
- webshoppingapigw
- webmarketingapigw

View File

@ -1,5 +1,7 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using System.IO;
namespace OcelotApiGw
{
@ -7,12 +9,16 @@ namespace OcelotApiGw
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.SetBasePath(Directory.GetCurrentDirectory());
config.AddJsonFile(Path.Combine("configuration", "configuration.json"));
config.AddCommandLine(args);
})
.UseStartup<Startup>()
.Build();
.Build()
.Run();
}
}
}

View File

@ -45,7 +45,7 @@ namespace OcelotApiGw.Services
Task.WaitAll(tasks.Select(task => task()).ToArray());
return string.Concat(strings);
return string.Join(',', strings);
}
}
}

View File

@ -17,7 +17,7 @@ namespace OcelotApiGw
{
public class Startup
{
private readonly IConfiguration _configuration;
private IConfiguration _configuration;
public Startup(IConfiguration configuration)
{
@ -59,13 +59,13 @@ namespace OcelotApiGw
var config = new ConfigurationBuilder()
.AddConfiguration(_configuration);
var cfg = services.BuildServiceProvider()
_configuration = services.BuildServiceProvider()
.GetServices<IOrchestratorStrategy>()
.Single(strategy => strategy.OrchestratorType == orchestratorType)
.ConfigureOrchestrator(config)
.Build();
services.AddOcelot(cfg);
services.AddOcelot(_configuration);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)