问题
I'm running this command in the Azure PowerShell to deploy my node project:
Publish-AzureServiceProject -ServiceName <name> -Location "East US"
Using my service name instead of <name>
.
Each time I run this, I get an error:
Publish-AzureServiceProject : Object reference not set to an instance of an
object.
At line:1 char:1
+ Publish-AzureServiceProject -ServiceName <name> -Location "East US"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Publish-AzureServiceProject], N
ullReferenceException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.CloudService.Pub
lishAzureServiceProjectCommand
Can anyone help? I've found similar questions here referencing deployment from Visual Studio, but I don't know how to (or if I can or should) take the steps advised for those problems since I'm building a node project from the command line.
UPDATE: Confirmed that I have added my certificate. This is apparently part of the publish profile import. I have also tried the manual authentication method, but neither seems to work. I'm still getting exactly the same error.
UPDATE 2: The command fails with the same error if I run Publish-AzureServiceProject
while in this directory even without any parameters. This leads me to believe incorrect parameter values are not the issue.
I now believe the issue is with my ServiceDefinition.csdef although I'm not sure. I started a new Node app just to test publishing. I was able to start publishing and get further than I'm getting with this app even without creating the new service in Azure.
Here's my ServiceDefinition.csdef. I've removed the service name in case that could be a security risk.
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="<name>" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WorkerRole name="CoreServer" vmsize="ExtraSmall">
<Startup>
<Task commandLine="setup_worker.cmd > log.txt" executionContext="elevated">
<Environment>
<Variable name="EMULATED">
<RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
</Variable>
<Variable name="RUNTIMEID" value="node" />
<Variable name="RUNTIMEURL" value="http://az413943.vo.msecnd.net/node/0.8.4.exe" />
</Environment>
</Task>
<Task commandLine="node.cmd .\startup.js" executionContext="elevated" />
</Startup>
<LocalResources>
<LocalStorage name="AGS_Working_Directory" sizeInMB="1024" />
</LocalResources>
<Endpoints>
<InputEndpoint name="HttpIn" protocol="tcp" port="80" />
</Endpoints>
<Runtime>
<Environment>
<Variable name="PORT">
<RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='HttpIn']/@port" />
</Variable>
<Variable name="EMULATED">
<RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
</Variable>
</Environment>
<EntryPoint>
<ProgramEntryPoint commandLine="node.cmd .\server.js" setReadyOnProcessStart="true" />
</EntryPoint>
</Runtime>
</WorkerRole>
</ServiceDefinition>
DeployTesting.ps1 script:
$scriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent
Set-Location $ScriptDir
Copy-Item $ScriptDir\CoreServer\node_modules\dbResources.js.test -Destination $scriptDir\CoreServer\node_modules\dbResources.js
Publish-AzureServiceProject -ServiceName <name> -Location "East US" -Slot staging
Issue posted on Github: https://github.com/Azure/azure-sdk-tools/issues/2463
回答1:
Which version of PowerShell are you using?
My guess is that one of the files that makes up the service is missing from the place powersahell expects it. The newer versions of PowerShell require the following files in the service directory:
(1) ServiceDefinition.csdef (2) ServiceConfiguration.Cloud.cscfg (3) ServiceConfguration.Local.cscfg (4) A directory with your role files, with name matching the role name
Older versions also require
deploymentSettings.json
Please file a bug as Ogail suggests and include your service directory details
Or github url has changed, it is now
https://github.com/Azure/azure-sdk-tools/issues
回答2:
Could you please file an issue on https://github.com/WindowsAzure/azure-sdk-tools/issues/ and attach your service project folder? This will help in debugging the problem.
Thanks, Elogeel
来源:https://stackoverflow.com/questions/23205496/object-reference-not-set-to-an-instance-of-an-object-when-i-try-to-deploy-my-a