草庐IT

java - 无法以编程方式创建 AZURE VM

coder 2024-06-05 原文

我们正在尝试使用 Azure 公开的 REST API 通过 Java 中的 HTTPClient 创建虚拟机。我们正在使用以下请求 URL 和 XML,但我们收到“错误请求”响应。

https://management.core.windows.net/ {subscription-id}/services/hostedservices/{existing hoster service name}/deployments

<Deployment xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <Name>TestVMAnandP</Name>
  <Label>bXl2bQ==</Label>
  <RoleList>
    <Role>
      <RoleName>TestVMAnandP</RoleName>
      <RoleType>PersistentVMRole</RoleType>
      <ConfigurationSets>
        <ConfigurationSet>
          <ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType>
          <HostName>TestVMAnandP</HostName>
          <UserName>root</UserName>
          <UserPassword>test</UserPassword>
        </ConfigurationSet>
      </ConfigurationSets>
      <DataVirtualHardDisks>
        <DataVirtualHardDisk>
          <Lun>10</Lun>
          <LogicalDiskSizeInGB>50</LogicalDiskSizeInGB>
        </DataVirtualHardDisk>
      </DataVirtualHardDisks>
      <OSVirtualHardDisk>
        <SourceImageName>srini2-srini2-2012-08-23.vhd</SourceImageName>
        <MediaLink>http://sriniteststore.blob.core.windows.net/vhds/srini2-srini2-2012-08-23.vhd</MediaLink>
      </OSVirtualHardDisk>
      <RoleSize>ExtraSmall</RoleSize>
    </Role>
  </RoleList>
  <VirtualNetworkName>MyNetwork</VirtualNetworkName>
</Deployment>

如果我们尝试在 URL 中提供与虚拟机名称相同的服务名称,我们将收到 404 错误。我们已经尝试了网络中提供的大多数示例,并替换了值,但一切都给了我们一个 400 错误。如果我们能得到一些帮助,那就太好了。

错误:

我遇到了两种不同类型的错误:


Error 1 : When i use new <service-name> inside the below URL .management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/deployments/                          -------------------------------------------------------------------   Response message--->Not Found---404
java.io.FileNotFoundException: management.core.windows.net/84cc18f5-5bdd-4c95-9d69-862c12c53507/services/hostedservices/anand/deployments
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
Caused by: java.io.FileNotFoundException: management.core.windows.net/84cc18f5-5bdd-4c95-9d69-862c12c53507/services/hostedservices/anand/deployments
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)

Error 2 : when i use an existing available <service-name> in the below URL  management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/deployments/                                                   
Response message--->Bad Request---400
java.io.IOException: Server returned HTTP response code: 400 for URL: management.core.windows.net/84cc18f5-5bdd-4c95-9d69-862c12c53507/services/hostedservices/azurecogservice/deployments
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: management.core.windows.net/84cc18f5-5bdd-4c95-9d69-862c12c53507/services/hostedservices/azurecogservice/deployments
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)

--------------------有效的 XML------------------------ --------------------------------------

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsazure">
    <Name>190bed4a</Name>
    <DeploymentSlot>Production</DeploymentSlot>
    <Label>190bed4a</Label>
    <RoleList>
        <Role>
            <RoleName>SuseOpenVm_rolec8fc</RoleName>
            <RoleType>PersistentVMRole</RoleType>
            <ConfigurationSets>
                <ConfigurationSet>
                    <ConfigurationSetType>LinuxProvisioningConfiguration
                    </ConfigurationSetType>
                    <HostName>SuseOpenVm_rolec8fc</HostName>
                    <UserName>anandsrinivasan</UserName>
                    <UserPassword>Cloud360</UserPassword>
                    <DisableSshPasswordAuthentication>false</DisableSshPasswordAuthentication>
                </ConfigurationSet>
                <ConfigurationSet>
                    <ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
                    <DisableSshPasswordAuthentication>false</DisableSshPasswordAuthentication>
                    <InputEndpoints>
                        <InputEndpoint>
                            <LocalPort>22</LocalPort>
                            <Name>SSH</Name>
                            <Port>22</Port>
                            <Protocol>TCP</Protocol>
                        </InputEndpoint>
                    </InputEndpoints>
                </ConfigurationSet>
            </ConfigurationSets>
            <OSVirtualHardDisk>
                <MediaLink>https://portalvhdsvf842yxvkhbg4.blob.core.windows.net/vhds/190bed4a.vhd</MediaLink>
                <SourceImageName>SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd</SourceImageName>
            </OSVirtualHardDisk>
            <RoleSize>Small</RoleSize>
        </Role>
    </RoleList>
    <VirtualNetworkName>anand360NW</VirtualNetworkName>
</Deployment>

最佳答案

每当我遇到 REST API 问题时,我都会首先尝试通过门户完成我想做的事情。在您的情况下,我尝试使用用户名 root 和密码 test 创建一个 Linux VM (TestVMAnandP)。我立即注意到以下错误:

  • 不允许使用用户名“root”
  • 密码应至少为 8 个字符
  • 密码应包含以下 3 项:
    • 一个小写字符
    • 一个大写字符
    • 一个数字
    • 一个特殊的角色

关于java - 无法以编程方式创建 AZURE VM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12559207/

有关java - 无法以编程方式创建 AZURE VM的更多相关文章

  1. ruby - 如何在 Ruby 中顺序创建 PI - 2

    出于纯粹的兴趣,我很好奇如何按顺序创建PI,而不是在过程结果之后生成数字,而是让数字在过程本身生成时显示。如果是这种情况,那么数字可以自行产生,我可以对以前看到的数字实现垃圾收集,从而创建一个无限系列。结果只是在Pi系列之后每秒生成一个数字。这是我通过互联网筛选的结果:这是流行的计算机友好算法,类机器算法:defarccot(x,unity)xpow=unity/xn=1sign=1sum=0loopdoterm=xpow/nbreakifterm==0sum+=sign*(xpow/n)xpow/=x*xn+=2sign=-signendsumenddefcalc_pi(digits

  2. python - 如何使用 Ruby 或 Python 创建一系列高音调和低音调的蜂鸣声? - 2

    关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。

  3. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  4. ruby - 如何以所有可能的方式将字符串拆分为长度最多为 3 的连续子字符串? - 2

    我试图获取一个长度在1到10之间的字符串,并输出将字符串分解为大小为1、2或3的连续子字符串的所有可能方式。例如:输入:123456将整数分割成单个字符,然后继续查找组合。该代码将返回以下所有数组。[1,2,3,4,5,6][12,3,4,5,6][1,23,4,5,6][1,2,34,5,6][1,2,3,45,6][1,2,3,4,56][12,34,5,6][12,3,45,6][12,3,4,56][1,23,45,6][1,2,34,56][1,23,4,56][12,34,56][123,4,5,6][1,234,5,6][1,2,345,6][1,2,3,456][123

  5. ruby - 解析 RDFa、微数据等的最佳方式是什么,使用统一的模式/词汇(例如 schema.org)存储和显示信息 - 2

    我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i

  6. ruby - 使用 Vim Rails,您可以创建一个新的迁移文件并一次性打开它吗? - 2

    使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta

  7. ruby-on-rails - 无法使用 Rails 3.2 创建插件? - 2

    我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby​​1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在

  8. ruby - 无法运行 Rails 2.x 应用程序 - 2

    我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby​​:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r

  9. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  10. ruby - 如何使用 RSpec::Core::RakeTask 创建 RSpec Rake 任务? - 2

    如何使用RSpec::Core::RakeTask初始化RSpecRake任务?require'rspec/core/rake_task'RSpec::Core::RakeTask.newdo|t|#whatdoIputinhere?endInitialize函数记录在http://rubydoc.info/github/rspec/rspec-core/RSpec/Core/RakeTask#initialize-instance_method没有很好的记录;它只是说:-(RakeTask)initialize(*args,&task_block)AnewinstanceofRake

随机推荐