“对象引用未设置为对象的实例"当我尝试通过CLI部署Azure云服务时 [英] "Object reference not set to an instance of an object" when I try to deploy my Azure Cloud Service via CLI

查看:89
本文介绍了“对象引用未设置为对象的实例"当我尝试通过CLI部署Azure云服务时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Azure PowerShell中运行以下命令来部署我的节点项目:

Publish-AzureServiceProject -ServiceName <name> -Location "East US"

使用我的服务名称而不是<name>.

每次运行此命令时,都会出现错误:

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

任何人都可以帮忙吗?我在这里找到了类似的问题,这些问题涉及从Visual Studio进行部署,但是我不知道如何(或者是否可以或应该)采取针对这些问题的建议步骤,因为我是从命令行构建节点项目的./p>

更新:确认我已添加证书.这显然是发布配置文件导入的一部分.我也尝试了手动身份验证方法,但似乎都没有用.我仍然遇到完全相同的错误.

更新2:即使在没有任何参数的情况下在此目录中运行Publish-AzureServiceProject时,命令也会失败,并显示相同的错误.这使我相信不正确的参数值不是问题.

我现在确定问题出在我的ServiceDefinition.csdef上,尽管我不确定.我启动了一个新的Node应用程序,只是为了测试发布.即使没有在Azure中创建新服务,我也可以开始发布并获得比使用此应用程序更进一步的信息.

这是我的ServiceDefinition.csdef.万一可能会带来安全隐患,我已删除了服务名称.

<?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 &gt; 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脚本:

$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

发布在Github上的问题: https://github.com/Azure/azure -sdk-tools/issues/2463

解决方案

您正在使用哪个版本的PowerShell?

我的猜测是,组成该服务的文件之一在powersahell期望的位置丢失了.较新版本的PowerShell需要在服务目录中包含以下文件:

(1)ServiceDefinition.csdef (2)ServiceConfiguration.Cloud.cscfg (3)ServiceConfguration.Local.cscfg (4)包含您的角色文件的目录,其名称与角色名称匹配

旧版本也需要

deploymentSettings.json

请按照Ogail的建议提交错误,并提供您的服务目录详细信息

或者github网址已更改,现在是

https://github.com/Azure/azure-sdk-tools/issues

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 &gt; 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

解决方案

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

这篇关于“对象引用未设置为对象的实例"当我尝试通过CLI部署Azure云服务时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆