0

I'm doing some proof of concept work on azure, trying to get a role using the Get Role URL:

https://management.core.windows.net/<subscription-id>/services/hostedservices/<cloudservice-name>/deployments/<deployment-name>/roles/<role-name>

And then update the role using the Update Role URL:

https://management.core.windows.net/<subscription-id>/services/hostedservices/<cloudservice-name>/deployments/<deployment-name>/roleinstances/<role-name>

Both of those URLs are straight from the msdn pages. The GET request works and I get XML that matches what I see in the management console. When I then add an element to the xml and send that back with a PUT on the update URL, I get a 200 response, but I never see the change in the management console. I also don't see any error message when I send gibberish. I'm connecting from C#, and a coworker suggested I could get the response with this:

var response = (HttpWebResponse)request.GetResponse();
Console.WriteLine(response.ToString());

But that gets me a 404 error.

Is there an extra step to commit the update? And how can I see the response that msdn mentions?

4

2 回答 2

0

我有同样的问题。就我而言,EndPointACL 没有得到更新。非常痛苦的是每次更新,我们都要发送整个 ConfigurationSet;无法更新特定端点的 ACL。

典型的更新如下所示:

<?xml version="1.0"?>
<PersistentVMRole xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ConfigurationSets>
    <ConfigurationSet>
        <ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
        <InputEndpoints>
            <InputEndpoint>
                <LocalPort>100</LocalPort>
                <Name>TCP-100</Name>
                <Port>100</Port>
                <Protocol>tcp</Protocol>
                <EndpointACL>
            <Rules>
              <Rule>
                <Order>1</Order>
                <Action>deny</Action>
                <RemoteSubnet>108.239.229.0/24</RemoteSubnet>
                <Description>test-rule</Description>
              </Rule>
            </Rules>
          </EndpointACL>
            </InputEndpoint>
        </InputEndpoints>
        <SubnetNames>
            <SubnetName>Subnet-1</SubnetName>
        </SubnetNames>
    </ConfigurationSet>
</ConfigurationSets>
</PersistentVMRole>
于 2014-04-20T06:31:41.467 回答
0

2条建议:

  1. 当我只是在做快速的 SMAPI 工作时,我使用 AzureTools ( http://blogs.msdn.com/b/kwill/archive/2013/08/26/azuretools-the-diagnostic-utility-used-by-the-windows- azure-developer-support-team.aspx)。具体来说,请查看“服务管理 REST API”下的“杂项工具”部分。这将向您显示完整的响应。

  2. 要回答有关如何获取响应的问题(txtSMAPIResponse 是 AzureTools 放置响应信息的位置):

            System.IO.Stream receiveStream;
        System.IO.StreamReader readStream;
        Encoding encode;
    
        HttpWebResponse response = null;
        try
        {
            response = (HttpWebResponse)request.GetResponse();
        }
        catch (WebException ex)
        {
            txtSMAPIRequest.Text = request.Headers.ToString();
            txtSMAPIResponse.Text = ex.Message + Environment.NewLine + Environment.NewLine + ex.Response.Headers.ToString();
            try
            {
                receiveStream = ex.Response.GetResponseStream();
                encode = System.Text.Encoding.GetEncoding("utf-8");
                // Pipes the stream to a higher level stream reader with the required encoding format. 
                readStream = new System.IO.StreamReader(receiveStream, encode);
                txtSMAPIResponse.Text += readStream.ReadToEnd();
    
                // Releases the resources of the response.
                response.Close();
                // Releases the resources of the Stream.
                readStream.Close();
            }
            catch
            {
            }
            return;
        }
    
        txtSMAPIRequest.Text = request.Method + " " + request.RequestUri + " " + request.ProtocolVersion + Environment.NewLine + Environment.NewLine;
        txtSMAPIRequest.Text += request.Headers.ToString();
        txtSMAPIResponse.Text = (int)response.StatusCode + " - " + response.StatusDescription + Environment.NewLine + Environment.NewLine;
        txtSMAPIResponse.Text += response.Headers + Environment.NewLine + Environment.NewLine;
    
        receiveStream = response.GetResponseStream();
        encode = System.Text.Encoding.GetEncoding("utf-8");
        // Pipes the stream to a higher level stream reader with the required encoding format. 
        readStream = new System.IO.StreamReader(receiveStream, encode);
        txtSMAPIResponse.Text += readStream.ReadToEnd();
    
        // Releases the resources of the response.
        response.Close();
        // Releases the resources of the Stream.
        readStream.Close();
    }
    
于 2013-10-03T20:52:09.373 回答