未启用Azure云服务启动任务

问题描述:

我试图部署天蓝色云服务Web角色,这是一个简单的应用程序,用于测试通过odbc连接到Hive。为此,我需要在启动应用程序之前在机器上安装配置单元odbc驱动程序,这就是为什么我添加了一个启动任务,它调用powershell脚本来下载驱动程序,而不是像这样安装它:未启用Azure云服务启动任务

STARTUP.CMD

@echo off 
powershell -command "Set-ExecutionPolicy Unrestricted" 2>> err.out 
powershell .\dlHiveOdbcDriver.ps1 2>> err.out 
hiveodbc.msi /passive 

dlHiveOdbcDriver.ps1

(new-object system.net.webclient).downloadfile('https://download.microsoft.com/download/F/4/A/F4A2CA7D-5D14-4177-A7CE-B938EF3F3C24/HiveODBC32.msi', 'hiveodbc.msi') 

我serviceDefinition服务具有下面的代码申报启动任务

<WebRole name="SomeTest" vmsize="ExtraSmall"> 
    <Startup> 
     <Task commandLine="startup.cmd" taskType="simple" executionContext="elevated" /> 
    </Startup> 
... 
</WebRole> 

然而,当我部署的应用程序,我仍然得到以下错误

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified 

其影射未安装驱动程序。 我试过重新启动应用程序,确保所有pre-requisites (scripts in root folder, copy always, executionPolicy etc')已被应用,但无济于事。 不幸的是,我不能远程进入机器当前,由于办公室问题...

任何帮助将不胜感激。

我差点忘了更新它。 事实证明,Azure默认使用x64体系结构为其在其Cloud Service Web角色中的虚拟机上承载的IIS网站使用。最重要的是,他们还预先安装了一个Hive odbc驱动程序,但是他们使用x86驱动程序而不是x64驱动程序。我正在尝试安装x86驱动程序 - 所以任务正常运行。 I have raised an issue with Azure来解决这个问题,以防万一谁也遭遇这个问题。

真正有助于远程访问,以便排除故障。我建议你从一台可以实际测试的PC上尝试它。

但继承人我的做法。在ServiceDefinition.csdef中我有以下几点:

<Task commandLine=".\startuptasks\bootstrap.cmd" executionContext="elevated" taskType="simple"> 
    </Task> 

我用这个bootstrap.cmd脚本安装第三方组件:一个安装*的.ps1文件

ECHO The current version is %MyVersionNumber% >> ".\StartupLog.txt" 2>&1 

cd startuptasks 

PowerShell -Command "Set-Executionpolicy Unrestricted" >> ".\excutionploicylog.txt" 2>&1 
PowerShell .\installCCP.ps1 >> ".\CCPStartupLog.txt" 2>&1 
PowerShell .\installOTHERSTUFF.ps1 >> ".\GSStartupLog.txt" 2>&1 
EXIT /B 0 

内容是:

$source = "http://YOUR_ACCOUNT.blob.core.windows.net/installer/vcredist_x64.exe" 
$destination = "$($tempDir.Value)\vredistx64.exe" 
Invoke-WebRequest $source -OutFile $destination -Method Get 
$p1 = Start-Process $destination -ArgumentList " /quiet /norestart" -wait -NoNewWindow -PassThru 

确保使用“Copy if newer”将所有文件(.cmd和.ps1)复制到输出目录。

确保您可以使用Start-Process在本地进行安装。无声安装需要支持。

请让我知道这是否有帮助。