Wednesday, October 31, 2012

Could not provision App Management Service

I ran the Farm Configuration Wizard (gasp, yes I did) and it was mostly successful, but returned one error:

The service application(s) for the service "App Management Service" could not be provisioned because of the following error: Cannot open database "AppMng_Service_DB_c394cb934e0e483e9fff60b31aeaeb35" requested by the login. The login failed. Login failed for user '[some user]'

ULS is showing the following:

Failed to provision service application App Management Service System.Data.SqlClient.SqlException (0x80131904): Cannot open database "AppMng_Service_DB_c394cb934e0e483e9fff60b31aeaeb35" requested by the login. The login failed.  Login failed for user '[some user]'.    
 at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)    
 at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)    
 at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)    
 at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)    
 at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)    
 at System.Data.SqlClient.SqlConnection.Open()    
 at Microsoft.SharePoint.Utilities.SqlSession.OpenConnection()    
 at Microsoft.SharePoint.Utilities.SqlSession.ExecuteReader(SqlCommand command, CommandBehavior behavior, SqlQueryData monitoringData, Boolean retryForDeadLock)    
 at Microsoft.SharePoint.Utilities.SqlSession.ExecuteReader(SqlCommand command, Boolean retryForDeadLock)    
 at Microsoft.SharePoint.Utilities.SqlSession.ExecuteReader(SqlCommand command)    
 at Microsoft.SharePoint.Upgrade.SPDatabaseSequence.GetVersion(SPDatabase database, Guid id, Version defaultVersion, SqlSession session, SPDatabaseSequence sequence)    
 at Microsoft.SharePoint.Upgrade.SPDatabaseSequence.GetVersion(Guid id, Version defaultVersion)    
 at Microsoft.SharePoint.Upgrade.SPDatabaseSequence.SetVersion(Guid id, Version version)    
 at Microsoft.SharePoint.Upgrade.SPDatabaseWssSequence.set_BuildVersion(Version value)    
 at Microsoft.SharePoint.Upgrade.SPSequence.set_NeedsUpgrade(Boolean value)    
 at Microsoft.SharePoint.Upgrade.SPUpgradeSession.NeedsUpgradeFalse(Object o)    
 at Microsoft.SharePoint.Administration.SPPersistedUpgradableObject.set_NeedsUpgrade(Boolean value)    
 at Microsoft.SharePoint.AppManagement.AppManagementServiceDatabase.Provision()    
 at Microsoft.SharePoint.AppManagement.AppManagementServiceApplication.Provision()    
 at Microsoft.SharePoint.Administration.SPAdminConfigServicesJob.Execute(Guid targetInstanceId)  ClientConnectionId:6b54fce5-06bc-4e2f-b6a9-c7d548253480 Source: .Net SqlClient Data Provider Server: AMAZONA-V5PUF8S LineNumber: 65536 StackTrace: 
 at onetnative.dll: (sig=6aba1f5f-ccc4-4590-af00-b8ffe7fe99a0|2|onetnative.pdb, offset=28BE6)
 at onetnative.dll: (offset=152A9)

However, SQL is not showing any connection attempts at that time, success or fail. I also verified that the account indeed has access to that database.

Regardless, it looks like the service application did get provisioned. Perhaps I will reprovision it.

More to come ...

Monday, October 29, 2012

Read-Host that is not assigned to a variable is added to return value

The best way I can illustrate this is as follows. Given this code for test.ps1:

Read-Host "Hit enter to continue"

try {
    throw system.exception
} catch {
    return $null

When I call test.ps1 I can expect a $null value, right? No. This is what happens:

> $a=.\test.ps1
Hit enter to continue:
> $a

> $a -eq $null
> $a.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Object[]                                 System.Array

> $a.Count
> $a[0]

> $a[1]
> $a[1] -eq $null

One would expect $a -eq $null to be true. Instead, $a is an array where the first value is that of Read-Host and the second value is the expected $null. 

So, I changed my code to the following:

$HitEnter = Read-Host "Hit enter to continue"

try {
    throw system.exception
} catch {
    return $null

Now everything works as expected:

> $a=.\test.ps1
Hit enter to continue:
> $a -eq $null

[Update 2013-05-27] Aha - found the reason behind this. Uncaptured output is still returned as output. Reference: Function Output Consists of Everything That Isn’t Captured

Friday, October 19, 2012

SharePoint 2013 HTTP Error 500 and 503

At some point after a reboot / iisreset or something else, I found that I could no longer get to my SharePoint sites nor to Central Administration. Each page was returning HTTP Error 500 or 503.

Of course, any time this happens, you need to take a look at IIS Admin. So opening it up, I see that all my application pools were offline. That's strange, it was just working a moment ago. Opening up the Basic Settings, I see this:
For some reason the Start application pool immediately box was unchecked. I then proceeded to check all of them and restarted my application pools and everything now works fine.