Azure REST API:网络安全组/网络接口

时间:2018-12-17 15:49:56

标签: rest azure

我正在尝试将与Azure Cloud的概念验证集成构建到另一个系统中。我不是Azure主题专家,因此我在端到端集成方面苦苦挣扎。

我无法将“网络安全组”与“网络接口”相关联。我可以创建两者,但是只有在我手动进入Cloud Portal并进行关联之后,它们才能彼此关联。

我正在使用以下内容: API文档: https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines

API资源管理器: https://resources.azure.com

我依次呼叫以下端点:

publicIPAddresses https://management.azure.com/subscriptions/ {subscriptionID} / resourceGroups / {resourceGroup} /providers/Microsoft.Network/publicIPAddresses/ {resourceName}?api-version = 2018-07-01

networkInterfaces https://management.azure.com/subscriptions/ {subscriptionID} / resourceGroups / {resourceGroup} /providers/Microsoft.Network/networkInterfaces/ {resourceName}?api-version = 2018-07-01

networkSecurityGroups https://management.azure.com/subscriptions/ {subscriptionID} / resourceGroups / {resourceGroup} /providers/Microsoft.Network/networkSecurityGroups/ {resourceName}?api-version = 2018-07-01

virtualMachines:https://management.azure.com/subscriptions/ {subscriptionID} / resourceGroups / {resourceGroup} /providers/Microsoft.Compute/virtualMachines/ {resourceName}?$ expand = instanceView&api-version = 2018-06-01

除了与NIC关联的NSG之外,其他所有方法都有效。

在“ networkSecurityGroups”消息中,我在属性节点下传递了以下参数。

"networkInterfaces": [{
        "id": "/subscriptions/" + subscriptionID + "/resourceGroups/" + resourceGroup + "/providers/Microsoft.Network/networkInterfaces/" + networkInterfaces
    }
]

我已经尝试通过在Interface REST调用中引用NSG来反转它,但是仍然无法正常工作。奇怪的是,我使用相同的语法将接口与VM本身关联,并且可以按预期工作。相同语法的变体可以将PublicIP与接口,磁盘与VM等相关联。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

非常确定您需要在NIC属性部分下添加它:

<form name="form" action="" method="POST">
    <input type="text" name="search">
</form>
<?php

if(isset($_POST['search'])){
    $search = $_POST['search'];

    $servername = "localhost";
    $username = "username";
    $password = "password";
    $dbname = "myDB";

    $conn = new mysqli($servername, $username, $password, $dbname);
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 

    $sql = "SELECT A, B, C FROM Fnaf WHERE Name = '$search'";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        while($row = $result->fetch_assoc()) {
            echo $row['A'];
            echo $row['B'];
            echo $row['C'];
        }
    } else {
        echo "0 results";
    }
    $conn->close();
}