I've got a solution:
Solution1
--ConfigProject
----AppManifest.xml
----ServiceManifest.xml
--Project1
--Project2
ServiceManifest.xml looks like this:
<ServiceManifest>
...............
<Resources>
<Endpoints>
<!-- 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 Protocol="https" Name="ServiceEndpoint" Type="Input" />
</Endpoints>
</Resources>
</ServiceManifest>
Without relying on c# code, is there a pre-build step that I can add that will transform the Resources section in the ServiceManifest file, based on a setting in the AppManifest.xml file?
You could describe your service manifest as following:
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="Stateless1Pkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
<ResourceOverrides>
<Endpoints>
<Endpoint Name="ServiceEndpoint" Port="[Port]" Protocol="[Protocol]" Type="[Type]" />
<Endpoint Name="ServiceEndpoint1" Port="[Port1]" Protocol="[Protocol1] "/>
</Endpoints>
</ResourceOverrides>
<Policies>
<EndpointBindingPolicy CertificateRef="TestCert1" EndpointRef="ServiceEndpoint"/>
</Policies>
</ServiceManifestImport>
Now you can apply the parameters in your ApplicationManifest. If you want you can add them a default value.
<Parameters>
<Parameter Name="Port" DefaultValue="" />
<Parameter Name="Protocol" DefaultValue="" />
<Parameter Name="Type" DefaultValue="" />
<Parameter Name="Port1" DefaultValue="" />
<Parameter Name="Protocol1" DefaultValue="" />
</Parameters>
You can override these parameters with an own customized ApplicationParameters file (like Local1.1Node.xml and Local.5Node.xml). Another alternative would be to insert the parameters per powershell during publishing:
PS C:\> New-ServiceFabricApplication -ApplicationName fabric:/myapp -ApplicationTypeName "AppType" -ApplicationTypeVersion "1.0.0" -ApplicationParameter #{Port='1001'; Protocol='https'; Type='Input'; Port1='2001'; Protocol='http'}
For further details:
https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-service-manifest-resources
Related
Need to know how to add Placement Policy in application manifest.xml
I have this PS script
New-ServiceFabricService -ApplicationName fabric:/$appName123
-ServiceName fabric:/$appName123/MyApp1 -ServiceTypeName $serviceTypeName -Stateless –PartitionSchemeSingleton –PlacementPolicy
#(“AllowMultipleStatelessInstancesOnNode”) -InstanceCount 10
-ServicePackageActivationMode ExclusiveProcess
What will be the equivalent in ApplictionManifest.xml?
`
<Service Name="App" ServicePackageActivationMode="ExclusiveProcess">
<StatelessService ServiceTypeName="Service" InstanceCount="[InstanceCount]">
<SingletonPartition />
// this tag
<ServicePlacementPolicies>
<ServicePlacementPolicy Type="AllowMultipleStatelessInstancesOnNode" />
</ServicePlacementPolicies>
</StatelessService>
</Service>
`
get xml equivalent of powershell command
This I got from ChatGPT :). Yet to try this.
<ServiceManifestImport>
<ServiceTypeName>MyServiceType</ServiceTypeName>
<ServiceManifestRef ServiceManifestName="MyServiceManifest" ServiceManifestVersion="1.0.0" />
<PlacementPolicy>
<Policy Type="InvalidDomain" DomainName="MyPlacementPolicy" />
</PlacementPolicy>
</ServiceManifestImport>
I'm looking at implementing a runsettings file for automated testing. Thing is, my variables are complex objects, and all I can find in the documentation about runsettings has simple key/value options, like so.
<TestRunParameters>
<Parameter name="webAppUrl" value="http://localhost" />
<Parameter name="docsUrl" value="https://learn.microsoft.com" />
</TestRunParameters>
I'm wondering if it's possible to specify a complex object like you might specify below (especially since TextContext.Properties returns an object, so I assume it's polymorphic in some sense?) and cast it to a given defined class
<TestRunParameters>
<Parameter name="AdminUser" UserID="Admin" Password="P#55w0rd!" />
<Parameter name="User" UserID="User" Password="P#55w0rd!" />
</TestRunParameters>
I realize I can do the below and manually create my object instances, but I'd really really like to avoid it if at all possible
<TestRunParameters>
<Parameter name="AdminUserID" value="Admin"/>
<Parameter name="AdminUserPW" value="P#55w0rd!" />
<Parameter name="UserID" value="User"/>
<Parameter name="UserPW" value="P#55w0rd!" />
</TestRunParameters>
I am using a child class of the System.Data.Services.Client.DataServiceContext gerated by the "adding a Service Reference" in VisualStudio to access data via an OData service. The definition in the $metadata.xml of the service includes a custom operation:
<schema Namespace="dotNetBF.OData" xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
<EntityContainer Name="OData" m:IsDefaultEntityContainer="true">
<EntitySet Name="SewageArea" EntityType="GeoMan.SealingRegister.SewageArea" />
<EntitySet Name="LandParcel" EntityType="GeoMan.SealingRegister.LandParcel" />
...
<AssociationSet Name="GeoMan_SealingRegister_SewageArea_LandParcel_GeoMan_SealingRegister_LandParcel_LandParcelPartnerSet" Association="GeoMan.SealingRegister.GeoMan_SealingRegister_SewageArea_LandParcel_GeoMan_SealingRegister_LandParcel_LandParcelPartner">
<End Role="LandParcelPartner" EntitySet="SewageArea" />
<End Role="LandParcel" EntitySet="LandParcel" />
</AssociationSet>
...
<FunctionImport Name="LandParcelByRegistrationYear" EntitySet="LandParcel" ReturnType="Collection(GeoMan.SealingRegister.LandParcel)">
<Parameter Name="registrationYear" Mode="In" Type="Edm.String" />
</FunctionImport>
</EntityContainer>
</Schema>
How can I access the defined function LandParcelByRegistrationYear through the DataServiceDeviceContext, commit a value for parameter registrationYearand consume the result.
I already imported the $metadata.xml but cannot find a method given the name of the operation.
I am learning NLog and have moved on to Database logging. I have tried multiple examples on the web and can't get any of them to actually insert a record. I can't see why the log attempt failed due to NLog gobbling up any exceptions it gets. My logger and the config is found without issue. It executes the line as if it worked but the table remains empty. I did step for step on Nlog's example but it doesn't work either! :(
Nlog Database Example
UPDATE: I ended up deleting and starting over on the config and it now works. Not sure what fixed the issue from the new config file but i also realized the asp renders were causing errors so i removed them.
<target name="db"
xsi:type="Database"
dbProvider="System.Data.SqlClient"
connectionString="Data Source=Server;Initial Catalog=Database;Persist Security Info=True;Integrated Security=SSPI;"
commandType="StoredProcedure"
commandText="[dbo].[NLog_AddEntry_p]">
<parameter name="#machineName" layout="${machinename}" />
<parameter name="#siteName" layout="${iis-site-name}" />
<parameter name="#logged" layout="${date}" />
<parameter name="#level" layout="${level}" />
<parameter name="#username" layout="${aspnet-user-identity}" />
<parameter name="#message" layout="${message}" />
<parameter name="#logger" layout="${logger}" />
<parameter name="#properties" layout="${all-event-properties:separator=|}" />
<parameter name="#serverName" layout="${aspnet-request:serverVariable=SERVER_NAME}" />
<parameter name="#port" layout="${aspnet-request:serverVariable=SERVER_PORT}" />
<parameter name="#url" layout="${aspnet-request:serverVariable=HTTP_URL}" />
<parameter name="#https" layout="${when:inner=1:when='${aspnet-request:serverVariable=HTTPS}' == 'on'}${when:inner=0:when='${aspnet-request:serverVariable=HTTPS}' != 'on'}" />
<parameter name="#serverAddress" layout="${aspnet-request:serverVariable=LOCAL_ADDR}" />
<parameter name="#remoteAddress" layout="${aspnet-request:serverVariable=REMOTE_ADDR}:${aspnet-request:serverVariable=REMOTE_PORT}" />
<parameter name="#callSite" layout="${callsite}" />
<parameter name="#exception" layout="${exception:tostring}" />
</target>
try
{
int zero = 0;
int result = 100 / zero;
}
catch (Exception ex)
{
Logger filelogger = LogManager.GetLogger("filelogger");
Logger dblogger = LogManager.GetLogger("dblogger");
//filelogger.Error(ex, "Whoops");
dblogger.Error(ex, "Whoops");
}
The issue was with asp layout renders and missing a package for them. Also i had set the internalLogging flag to an invalid value. These corrections fixed the problem.
I'm testing a very simple script to try and run my ant build file from CruiseControl.NET. I followed the steps I found on the net of how to do this but i keep getting nAnt task failed in CruiseControl without any explanation and yet when i run the NAnt build script separately, it runs fine.
Can anybody take a look at my build script, the Ccnet.config file and the output in the log and point me in the right direction?
My XmLib.build NAnt file
<?xml version="1.0"?>
<project default="start">
<property name="code.directory" value="C:\SHS" />
<property name="server.code.directory" value="${code.directory}\XmLib" />
<property name="server.code.project" value="${server.code.directory}\XmLib.sln" />
<target name="start">
<echo message="Building XmLib Component " />
</target>
</project>
My output when I ran my build file using Nant.exe via command line.
Buildfile: file:///C:/SHS/Build Scripts/XmLib.build
Target framework: Microsoft .NET Framework 4.0
Target(s) specified: start
start:
[echo] Building XmLib Component
BUILD SUCCEEDED
Total time: 0.4 seconds.
My CruiseControl.NET config file
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<project name="XmLib">
<tasks>
<nant>
<executable>C:\Program Files (x86)\NAnt\bin\nant.exe</executable>
<baseDirectory>C:\SHS\Build Scripts</baseDirectory>
<buildFile>XmLib.build</buildFile>
<logger>NAnt.Core.XmlLogger</logger>
<targetList>
<target>start</target>
</targetList>
<buildTimeoutSeconds>80</buildTimeoutSeconds>
</nant>
</tasks>
<publishers>
<xmllogger logDir="C:\tmp" />
</publishers>
</project>
</cruisecontrol>
The error I get when I try to run this via CruiseControl.NET using its dashboard.
<cruisecontrol project="XmLib">
<request source="BUILDHPSMV" buildCondition="ForceBuild">Administrator triggered a build (ForceBuild) from BUILDHPSMV</request>
<parameters>
<parameter name="$CCNetArtifactDirectory" value="C:\Program Files (x86)\CruiseControl.NET\server\XmLib\Artifacts" />
<parameter name="$CCNetBuildCondition" value="ForceBuild" />
<parameter name="$CCNetBuildDate" value="2013-01-16" />
<parameter name="$CCNetBuildId" value="a7fb196a3193468e8d8505f7db7641d5" />
<parameter name="$CCNetBuildTime" value="17:06:44" />
<parameter name="$CCNetFailureTasks" value="System.Collections.ArrayList" />
<parameter name="$CCNetFailureUsers" value="System.Collections.ArrayList" />
<parameter name="$CCNetIntegrationStatus" value="Unknown" />
<parameter name="$CCNetLabel" value="1" />
<parameter name="$CCNetLastIntegrationStatus" value="Failure" />
<parameter name="$CCNetListenerFile" value="C:\Program Files(x86)\CruiseControl.NET\server\XmLib\Artifacts\XmLib_ListenFile.xml" />
<parameter name="$CCNetModifyingUsers" value="System.Collections.ArrayList" />
<parameter name="$CCNetNumericLabel" value="1" />
<parameter name="$CCNetProject" value="XmLib" />
<parameter name="$CCNetProjectUrl" value="http://BUILDHPSMV/ccnet" />
<parameter name="$CCNetRequestSource" value="BUILDHPSMV" />
<parameter name="$CCNetUser" value="Administrator" />
<parameter name="$CCNetWorkingDirectory" value="C:\Program Files(x86)\CruiseControl.NET\server\XmLib\WorkingDirectory" />
</parameters>
<modifications />
<integrationProperties>
<CCNetArtifactDirectory>C:\Program Files(x86)\CruiseControl.NET\server\XmLib\Artifacts</CCNetArtifactDirectory>
<CCNetBuildCondition>ForceBuild</CCNetBuildCondition>
<CCNetBuildDate>2013-01-16</CCNetBuildDate>
<CCNetBuildTime>17:06:44</CCNetBuildTime>
<CCNetFailureUsers />
<CCNetFailureTasks>
<task>NAntTask</task>
</CCNetFailureTasks>
<CCNetIntegrationStatus>Failure</CCNetIntegrationStatus>
<CCNetLabel>1</CCNetLabel>
<CCNetLastIntegrationStatus>Failure</CCNetLastIntegrationStatus>
<CCNetListenerFile>C:\Program Files(x86)\CruiseControl.NET\server\XmLib\Artifacts\XmLib_ListenFile.xml</CCNetListenerFile>
<CCNetModifyingUsers />
<CCNetNumericLabel>1</CCNetNumericLabel>
<CCNetProject>XmLib</CCNetProject>
<CCNetProjectUrl>http://BUILDHPSMV/ccnet</CCNetProjectUrl>
<CCNetRequestSource>BUILDHPSMV</CCNetRequestSource>
<CCNetWorkingDirectory>C:\Program Files(x86)\CruiseControl.NET\server\XmLib\WorkingDirectory</CCNetWorkingDirectory>
<CCNetUser>Administrator</CCNetUser>
<CCNetBuildId>a7fb196a3193468e8d8505f7db7641d5</CCNetBuildId>
<LastIntegrationStatus>Failure</LastIntegrationStatus>
<LastSuccessfulIntegrationLabel>UNKNOWN</LastSuccessfulIntegrationLabel>
<LastModificationDate>1/15/2013 5:06:44 PM</LastModificationDate>
</integrationProperties>
<build date="2013-01-16 17:06:44" buildtime="00:00:00" error="true"buildcondition="ForceBuild"></build>
</cruisecontrol>
Only a guess but I suspect unquoted paths as cause of the failure. Try "C:\Program Files (x86)\NAnt\bin\nant.exe" resp. "C:\SHS\Build Scripts".