Service Fabric and Entity Framework Migrations - entity-framework

I'm using Service Fabric with Entity Framework 6.1.3 . When I try to enable migration with 'Enable-Migrations' I have the error:
Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly
'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable."
At C:\repos\Gsa.Pops.Bookings\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:720 char:5
+ $domain.SetData('startUpProject', $startUpProject)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SerializationException
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetProjectTypes(Project project, Int32 shellVersion)
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.IsWebProject(Project project)
at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory)
at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName)
at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Object reference not set to an instance of an object.
I suppose that EF cannot find the connection string because the starting project is a Service Fabric Application (so no web.config but an ApplicationManifest.xml and multiple environment configurations)
Any clue?
Thanks,
Alberto

You could store your connection strings in the KeyVault in Azure, and then have your infrastructure project pull from there.

Please use the following command to enable the migration,
Enable-Migrations -EnableAutomaticMigrations -ProjectName <Project Name where migration folder will include> -StartUpProjectName <project name where connection string exist>

Related

How do I update ESXi 6.5 patch using ESXCLI in PowerShell

Trying to update ESXi 6.5 Patch using ESXiCLI within powershell. My path is pointing to a subfolder in datastore called MasterImages.
This is the the path name
/vmfs/volumes/MasterImages/Patches/ESXi650-20210704001/ESXi650-20210704001.zip
Commands being executed:
$argsInstall = $esxcli.software.profile.update.createargs()
$argsInstall.depot = $patchfilepath
$esxcli.software.vib.update.Invoke($argsInstall)
Below is the error received:
Message: EsxCLI.CLIFault.summary;
InnerText: [MetadataDownloadError] Could not download from depot at
zip:/vmfs/volumes/MasterImages/Patches/ESXi650-20210704001/ESXi650-20210704001.zip?index.xml, skipping
(('zip:/vmfs/volumes/MasterImages/Patches/ESXi650-20210704001/ESXi650-20210704001.zip?index.xml', '', "Error extracting index.xml from
/vmfs/volumes/MasterImages/Patches/ESXi650-20210704001/ESXi650-20210704001.zip: [Errno 2] No such file or directory:
'/vmfs/volumes/MasterImages/Patches/ESXi650-20210704001/ESXi650-20210704001.zip'")) url =
zip:/vmfs/volumes/MasterImages/Patches/ESXi650-20210704001/ESXi650-20210704001.zip?index.xml Please refer to the log file for more
details.EsxCLI.CLIFault.summary
At line:176 char:5
+ $esxcli.software.vib.update.Invoke($argsInstall)}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], MethodFault
+ FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.MethodFault
I was able to make an ESX7.0.1 update using $esxcli.software.vib.update.Invoke($argsInstall) but with 6.5 this also returns an error "not able to download from depot".
Assuming you are using the absolute path to the zipped file, please use the datastore UUID instead of the name
https://kb.vmware.com/s/article/2015834

ServiceStack License not found when using NUnit 3 through Console Runner in TeamCity

I am using a valid license key. But I keep getting this error:
ServiceStack.LicenseException : The free-quota limit on '10 ServiceStack Operations' has been reached. Please see https://servicestack.net to upgrade to a commercial license or visit https://github.com/ServiceStackV3/ServiceStackV3 to revert back to the free ServiceStack v3.
So far I have tried the following:
Storing my license key in app.config
Storing my license key in web.config
Adding my key as a System Environment Variable called "SERVICESTACK_LICENSE"
Adding my key as a System Property through TeamCity Build Parameters
Adding my key as a System Environment Variable through TeamCity Build Parameters
Adding my key by calling Licensing.RegisterLicense before running AppHost.Init
When adding my key as a System Environment Variable through TeamCity Build Parameters I instead get an exception from JsConfig:
System.TypeInitializationException : The type initializer for 'ServiceStack.Text.JsConfig' threw an exception.
----> System.TypeInitializationException : The type initializer for 'ServiceStack.LicenseUtils' threw an exception.
----> System.IO.FileLoadException : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at ServiceStack.Text.JsConfig.InitStatics()
at ServiceStack.AppHostHttpListenerPoolBase..ctor(String serviceName, Int32 poolSize, Assembly[] assembliesWithServices) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\AppHostHttpListenerPoolBase.cs:line 75
at ServiceStack.AppSelfHostBase..ctor(String serviceName, Assembly[] assembliesWithServices) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\AppSelfHostBase.cs:line 13
at Alstra.SG.Tests.AppSelfHost..ctor() in C:\TeamCity\buildAgent\work\a0903bf22b2d1e1c\Test\AppSelfHost.cs:line 31
at Alstra.SG.Tests.Private.BaseIntegrationTest..ctor() in C:\TeamCity\buildAgent\work\a0903bf22b2d1e1c\Test\Private\BaseIntegrationTest.cs:line 16
at Alstra.SG.Tests.Private.Integration.RespondentServiceTests..ctor()
--TypeInitializationException
at ServiceStack.LicenseUtils.Init()
at ServiceStack.Text.JsConfig..cctor() in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\JsConfig.cs:line 21
--FileLoadException
at System.MemoryExtensions.AsSpan(String text)
at ServiceStack.Text.Jsv.JsvReader`1.Parse(String value) in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\Jsv\JsvReader.Generic.cs:line 81
at ServiceStack.Text.TypeSerializer.DeserializeFromString[T](String value) in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\TypeSerializer.cs:line 67
at ServiceStack.LicenseUtils.ToLicenseKeyFallback(String licenseKeyText) in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\LicenseUtils.cs:line 446
at ServiceStack.LicenseUtils.RegisterLicense(String licenseKeyText) in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\LicenseUtils.cs:line 252
at ServiceStack.Net45PclExport.RegisterLicenseFromConfig() in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\PclExport.Net45.cs:line 140
at ServiceStack.LicenseUtils..cctor() in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\LicenseUtils.cs:line 135
When adding my key by calling Licensing.RegisterLicense before running AppHost.Init I get the following exception instead:
System.IO.FileLoadException : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at System.MemoryExtensions.AsSpan(String text)
at ServiceStack.Text.Jsv.JsvReader`1.Parse(String value) in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\Jsv\JsvReader.Generic.cs:line 81
at ServiceStack.Text.TypeSerializer.DeserializeFromString[T](String value) in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\TypeSerializer.cs:line 67
at ServiceStack.LicenseUtils.ToLicenseKeyFallback(String licenseKeyText) in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\LicenseUtils.cs:line 446
at ServiceStack.LicenseUtils.RegisterLicense(String licenseKeyText) in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\LicenseUtils.cs:line 252
at Alstra.SG.Tests.Private.BaseIntegrationTest..ctor() in C:\TeamCity\buildAgent\work\a0903bf22b2d1e1c\Test\Private\BaseIntegrationTest.cs:line 17
at Alstra.SG.Tests.Private.Integration.ActivityServiceTests..ctor()
Happy to get some help!
I believe the version of ServiceStack you are using was built with a different version of System.Runtime.CompilerServices.Unsafe than what you are using in your Test project and because bindingredirect are not working in this context.
See Does redirecting assembly binding work for unit testing with a test runner?
As a workaround, you can try changing System.Runtime.CompilerServices.Unsafe in Nuget Package Manager to 4.5.2.
This version matches the missing assembly, Version=4.0.4.1.
Edit: If you are using NUnit 3 in your NUnit build step, you can then specify "Path to application configuration file: " to point to your app.config.
This should solve the root problem and let you use the most current version of your Nuget packages (since the correct bindingRedirects will then be applied).

Ansible through WinRM: win_find throws OutOfMemoryException

I'm working on some Ansible playbooks that have to run on Windows Server 2008 with Powershell 3.
As part of one of these playbooks I do a win_find to get a list of files in a directory:
- name: filecheck
win_find:
paths: C:\dev\envs
register: envs
When I try to run the playbook, it runs correctly through preliminary operations (eg printing some debug variables) but then errors out when the above operation is executed:
"module_stderr": "Exception of type 'System.OutOfMemoryException' was thrown.\r\nAt line:60 char:9\r\n+ If (-not $obj.GetType)\r\n+ ~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : OperationStopped: (:) [], OutOfMemoryException\r\n + FullyQualifiedErrorId : System.OutOfMemoryException\r\n \r\n\r\n",
Now I don't see a scenario where a non-recursive find on a folder with three files would be able to consume 150MB of memory, let alone the 2048 that's been allocated to shells over WinRM.
Does anyone know how I can fix this issue or try and find the root cause?

What is the difference between ServiceFabricClusterConfiguration and ServiceFabricClusterManifest?

My question regards updating the configuration for a Service Fabric standalone Windows cluster.
What is the difference between ServiceFabricClusterConfiguration and ServiceFabricClusterManifest?
Suppose that I want to change the ApplicationPorts setting, I see these options:
Using ServiceFabricClusterConfiguration
use Get-ServiceFabricClusterConfiguration
edit the JSON file
Start an upgrade using Start-ServiceFabricClusterConfigurationUpgrade
or
Using ServiceFabricClusterManifest
Use Get-ServiceFabricClusterManifest
edit the XML file
Start an upgrade using
Register-ServiceFabricClusterPackage -Config -ClusterManifestPath "ClusterConfigv2.xml"
Start-ServiceFabricClusterUpgrade -ClusterManifestVersion 2 -Config
I tried to change ApplicationPorts via the ServiceFabricClusterManifest. We are now in a situation that the ApplicationPorts is different in the json (Get-ServiceFabricClusterConfiguration) than the value in the XML (Get-ServiceFabricClusterManifest)
My questions are:
What is the difference between the two approaches?
What is the approach I should take?
Since the different Get- commands give different results, which is the way to see the actual applied configuration?
update:
I get the following error when I run the Start-ServiceFabricClusterConfigurationUpgrade command.
Exception : System.Exception: Exception of type 'System.Exception' was thrown.
at System.Fabric.Interop.NativeClient.IFabricClusterManagementClient7.EndUpgradeConfiguration(IFabricAsyncOperationC
ontext context)
at System.Fabric.Interop.Utility.<>c__DisplayClassa.<WrapNativeAsyncInvoke>b__9(IFabricAsyncOperationContext context
)
at System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext context, Boolean expectedComplet
edSynchronously)
TargetObject : Microsoft.ServiceFabric.Powershell.ClusterConnection
CategoryInfo : NotSpecified: (Microsoft.Servi...usterConnection:ClusterConnection) [Start-ServiceFa...gurationUpgrade], Exception
FullyQualifiedErrorId : StartClusterConfigurationUpgradeErrorId,Microsoft.ServiceFabric.Powershell.StartClusterConfigurationUpgrade
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
PSMessageDetails :
For on premises deployments Start-ServiceFabricClusterConfigurationUpgrade is the supported mechanism and is the only one you should use. As long as you use only one mechanism you shouldn't receive inconsistent results.
The detailed error is in the trace logs. Could u provide the 2 JSON files? Also, a common error is to upgrade without updating the json config version, which is the "clusterConfigurationVersion" item on the JSON config.

Windows AppFabric - renamed server, config now not loading

My original server was called xyz and the config was as follows:
\xyz\AppFabricConfig\ClusterConfig.xml
We renamed the server and it is now called 123, but the config is still pointing to
\xyz\AppFabricConfig\ClusterConfig.xml
And giving the following error when trying to load:
Use-CacheCluster : ErrorCode<ERRCMS0001>:SubStatus<ES0001>:Error while trying t
o load configuration: An error occurred loading a configuration file: Logon fai
lure: unknown user name or bad password.
(\\xyz\AppFabricConfig\ClusterConfig.xml)
At line:1 char:62
+ Import-Module DistributedCacheAdministration;Use-CacheCluster <<<<
+ CategoryInfo : NotSpecified: (:) [Use-CacheCluster], DataCacheE
xception
+ FullyQualifiedErrorId : ERRCMS0001,Microsoft.ApplicationServer.Caching.C
ommands.UseCacheClusterCommand
I've manually edited the following file:
C:\Windows\System32\AppFabric\DistributedCacheService.exe.config
And set: configuration/dataCacheConfig/clusterConfig connectionString="\123\AppFabricConfig\ClusterConfig.xml"
But its still trying to load from:
\xyz\AppFabricConfig\ClusterConfig.xml
Stumped - close to re-installing, but would really prefer not too!
In hind sight, best way to handle this would've been unconfigure the hosts with remove-cachehost and remove-cacheadmin, rename server and then run config wizard or run add-cachehost and add-cacheadmin.
The connection string is also present in registry, change there also: local machine\software\microsoft\appfabric\v1.0\configuration: connectionstring.
[Edit]
To remove/add the host from cluster configuration, Register-cachehost and unregister-cachehost also need to be run.