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

View File

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?> <?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"> <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 --> <!-- Add your custom configuration sections and parameters here -->
<!-- <!--<Section Name="ServiceFabricSettings">
<Section Name="MyConfigSection"> <Parameter Name="UrlMobilMarketing" Value="configuration/mobile/marketing" />
<Parameter Name="MyParameter" Value="Value1" /> <Parameter Name="UrlMobilShopping" Value="/configuration/mobile/shopping" />
</Section> <Parameter Name="UrlWebMarketing" Value="/configuration/web/marketing" />
--> <Parameter Name="UrlWebShopping" Value="/configuration/web/shopping" />
</Section>-->
</Settings> </Settings>

View File

@ -17,9 +17,18 @@
<Program>ApiGw_Base.exe</Program> <Program>ApiGw_Base.exe</Program>
<WorkingFolder>CodePackage</WorkingFolder> <WorkingFolder>CodePackage</WorkingFolder>
</ExeHost> </ExeHost>
<!--<ContainerHost>
<ImageName>eshop/sf.linux.settings.api:#{tag}#</ImageName>
</ContainerHost>-->
</EntryPoint> </EntryPoint>
<EnvironmentVariables> <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> </EnvironmentVariables>
</CodePackage> </CodePackage>
@ -32,6 +41,7 @@
<!-- This endpoint is used by the communication listener to obtain the port on which to <!-- 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 listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. --> 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" /> <Endpoint Protocol="https" Name="ServiceEndpoint" Type="Input" Port="8912" />
</Endpoints> </Endpoints>
</Resources> </Resources>

View File

@ -1,5 +1,4 @@
{ {
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": { "iisSettings": {
"windowsAuthentication": false, "windowsAuthentication": false,
"anonymousAuthentication": true, "anonymousAuthentication": true,
@ -8,6 +7,7 @@
"sslPort": 44363 "sslPort": 44363
} }
}, },
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": { "profiles": {
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
@ -21,10 +21,15 @@
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "api/values", "launchUrl": "api/values",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "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"> <EnvironmentOverrides CodePackageRef="code">
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="[ApiGw_Base_ASPNETCORE_ENVIRONMENT]" /> <EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="[ApiGw_Base_ASPNETCORE_ENVIRONMENT]" />
</EnvironmentOverrides> </EnvironmentOverrides>
<!--<Policies>
<ContainerHostPolicies CodePackageRef="Code">
<PortBinding ContainerPort="80" EndpointRef="sf.linux.settings.api.endpoint" />
</ContainerHostPolicies>
</Policies>-->
</ServiceManifestImport> </ServiceManifestImport>
<DefaultServices> <DefaultServices>
<!-- The section below creates instances of service types, when an instance of this <!-- The section below creates instances of service types, when an instance of this
@ -20,7 +25,7 @@
ServiceFabric PowerShell module. ServiceFabric PowerShell module.
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. --> 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]"> <StatelessService ServiceTypeName="ApiGw_BaseType" InstanceCount="[ApiGw_Base_InstanceCount]">
<SingletonPartition /> <SingletonPartition />
</StatelessService> </StatelessService>

View File

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

View File

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

View File

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

View File

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

View File

@ -45,7 +45,7 @@ namespace OcelotApiGw.Services
Task.WaitAll(tasks.Select(task => task()).ToArray()); 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 public class Startup
{ {
private readonly IConfiguration _configuration; private IConfiguration _configuration;
public Startup(IConfiguration configuration) public Startup(IConfiguration configuration)
{ {
@ -59,13 +59,13 @@ namespace OcelotApiGw
var config = new ConfigurationBuilder() var config = new ConfigurationBuilder()
.AddConfiguration(_configuration); .AddConfiguration(_configuration);
var cfg = services.BuildServiceProvider() _configuration = services.BuildServiceProvider()
.GetServices<IOrchestratorStrategy>() .GetServices<IOrchestratorStrategy>()
.Single(strategy => strategy.OrchestratorType == orchestratorType) .Single(strategy => strategy.OrchestratorType == orchestratorType)
.ConfigureOrchestrator(config) .ConfigureOrchestrator(config)
.Build(); .Build();
services.AddOcelot(cfg); services.AddOcelot(_configuration);
} }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)