I am trying ot figure out how to create an orchard tenant site though the cli. I have found a few resources on the web, and they don't seem to work for me, or I am not using the commands correctly
My main site is called landlord, and i want to create a tenant site called tenant1. I have enabled multi-tenancy, and created several through the orchard landlord site, and I was able to set them up without any issues.
My steps:
Open up cmd window in bin folder, and type orchard, and that does an initilization, and gives me an orchard command prompt
The command that i found on the web is
Orchard.exe tenant add mytenant /Host:mytenant.mysite
I try to run
tenant add tenant1 /Host:tenant1.landlord
and this gives me an error that switch /host is not found
if I instead use
tenant add tenant1
it seems to work, as it says creating tenant1...
I am not sure what exactly is supposed to happen with this command, but I can't see the tenant site listed in the landlord site, and I am unable to setup the site through the CLI
The command I found for setup is
Orchard.exe setup /t:mytenant /SiteName:mytenant.mysite
/DatabaseTablePrefix:mytenant /AdminUsername:admin
/AdminPassword:password /DatabaseProvider:SQLServer
/DatabaseConnectionString:"Data Source=localhost;Initial Catalog=Orchard;Persist Security Info=True;User ID=sa;Password=password"
I took the connection string that I used to setup the landlord site, and there is no way I can get this to work.
setup /t:tenant1 /SiteName:tenant1.landlord
/DatabaseTablePrefix:tenant1 /AdminUsername:admin
/AdminPassword:password /DatabaseProvider:SQLServer
/DatabaseConnectionString:"server=xx.xxx.xxx.xxx;database=dbname;user id=user; pwd=thepw"
The error is:
No such host is known
Exception Details: System.ComponentModel.Win32Exception: No such host is known
Stack Trace:
[Win32Exception: No such host is known]
[SqlException: A network-related or instance-specific error occurred while estab
lishing a connection to SQL Server. The server was not found or was not accessib
le. Verify that the instance name is correct and that SQL Server is configured t
o allow remote connections. (provider: TCP Provider, error: 0 - No such host is
known.)]
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdent
ity identity, SqlConnectionString connectionOptions, SqlCredential credential, O
bject providerInfo, String newPassword, SecureString newSecurePassword, Boolean
redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData r
econnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTra
nsientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOp
tions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConn
ectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
I have already used the connection string, and I can access the db fine.
Not sure why either command is not working
Now that I go back to the browser to load my landlord site, it seems to be not working, and i get the error
Access to the path 'C:\inetpub\...\...\App_Data\Sites\tenant1\Settings.txt' is denied.
This is from the root that previously loaded my landlord site, I think that i have totally destroyed my site
Can anyone let me know the correct commands to use, and maybe where i went wrong?
Update
thanks, I used your advice and i was able to get my landlord site up and running again. Using your instructions, i was able to create a tenant through the cli (tenant2). Now I am have a problem viewing the tenants through the Landlord admin page, I get the error: Access to the path 'C:\inetpub\wwwroot....\App_Data\Sites\tenant2\Settings.txt' is denied.
System.UnauthorizedAccessException: Access to the path 'C:\inetpub\wwwroot....\App_Data\Sites\tenant2\Settings.txt' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost) at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost) at Orchard.Environment.Configuration.ShellSettingsManager.d__6.MoveNext() in C:\Users\Administrator\Downloads\Orchard-1.10.3\src\Orchard\Environment\Configuration\ShellSettingsManager.cs:line 54 at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Orchard.Environment.Configuration.ShellSettingsManager.Orchard.Environment.Configuration.IShellSettingsManager.LoadSettings() in C:\Users\Administrator\Downloads\Orchard-1.10.3\src\Orchard\Environment\Configuration\ShellSettingsManager.cs:line 23 at Orchard.MultiTenancy.Controllers.AdminController.Index() at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3d() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f()
Thanks
App_data\Sites\tenant1before trying again. And of course, make backups. Another thing to consider is access right that could explain why that connection string works in some contexts but not here. You might want to try with a command line running as administrator and see if it makes a difference. - Bertrand Le RoyApp_Datadirectory. You need to grant that access to the user the web site is running under. This is detailed in this doc topic: docs.orchardproject.net/en/latest/Documentation/Setup/… - Bertrand Le Roy