如何检索和更新服务的azure配置文件?

时间:2012-02-04 14:29:30

标签: c# xml azure configuration-files

我是Azure的新手。我希望能够检索服务配置文件,然后更改其中的值。我一开始就陷入困境,因为我不知道如何在检索配置文件时编辑配置文件,或者必须将其设置为编辑它的类型(XMLDocument等)。当我检索服务属性时,它返回以下XML

<?xml version="1.0" encoding="utf-8"?>
<HostedService xmlns="http://schemas.microsoft.com/windowsazure">
  <Url>hosted-service-url</Url>
  <ServiceName>hosted-service-name</ServiceName>
  <HostedServiceProperties>
    <Description>description</Description>
    <Location>location</Location>
    <AffinityGroup>affinity-group</AffinityGroup>
    <Label>base-64-encoded-name-of-the-service</Label>
  </HostedServiceProperties>
  <Deployments>
    <Deployment>
      <Name>deployment-name</Name>
      <DeploymentSlot>deployment-slot</DeploymentSlot>
      <PrivateID>deployment-id</PrivateID>
      <Status>deployment-status</Status>
      <Label>base64-encoded-deployment-label</Label>
      <Url>deployment-url</Url>
      <Configuration>base-64-encoded-configuration-file</Configuration>
      <RoleInstanceList>
        <RoleInstance>
          <RoleName>role-name</RoleName>
          <InstanceName>role-instance-name</InstanceName>
          <InstanceStatus>instance-status</InstanceStatus>
        </RoleInstance>
      </RoleInstanceList>
      <UpgradeDomainCount>upgrade-domain-count</UpgradeDomainCount>
      <RoleList>
        <Role>
          <RoleName>role-name</RoleName>
          <OsVersion>operating-system-version</OsVersion>
        </Role>
      </RoleList>
      <SdkVersion>sdk-version-used-to-create-package</SdkVersion>
      <InputEndpointList>
         <InputEndpoint>
            <RoleName>role-name</RoleName>
            <Vip>virtual-ip-address</Vip>
            <Port>port-number</Port>
         </InputEndpoint>
         …
      </InputEndpointList>
      <Locked>deployment-write-allowed-status</Locked>
      <RollbackAllowed>rollback-operation-allowed</RollbackAllowed>
    </Deployment>
  </Deployments>
</HostedService>

就像我说的那样,我想要做的是从这个XML中获取“base-64-encoded-configuration-file”并编辑它的值。但我无法弄清楚如何从上面的XML中获取配置文件。

任何帮助,甚至是正确方向上的一点,都会非常感激,欢呼。

2 个答案:

答案 0 :(得分:4)

您也可以使用Windows Azure Powershell Cmdlets

执行 Set-DeploymentConfiguration 会更新实例的配置值。

您可以找到许多关于如何在线学习powershell的教程,包括:

答案 1 :(得分:2)

下载csmanage库的源代码。它具有用于使用Azure Service Management API的示例和抽象层:http://code.msdn.microsoft.com/windowsazure/Windows-Azure-CSManage-e3f1882c