我正在尝试通过 API 将诊断扩展安装到现有的 Azure 云服务中。云服务分配了一个保留的 IP。我收到“<strong>在部署更新或升级期间无法添加、删除或更改保留的 IP”。当使用 ChangeConfigurationBySlot 这样做时。有谁知道让它工作的诀窍?这是 API 中的遗漏还是我做错了什么?
这是一个相关的代码片段:
var dep = client.Deployments.GetBySlot(resource.ServiceName, DeploymentSlot.Production);
var serviceConfig = XElement.Parse(dep.Configuration, LoadOptions.SetBaseUri);
var config = new DeploymentChangeConfigurationParameters(serviceConfig.ToString())
{
ExtendedProperties = dep.ExtendedProperties,
Mode = DeploymentChangeConfigurationMode.Auto,
TreatWarningsAsError = false,
Configuration = serviceConfig.ToString(),
ExtensionConfiguration = new ExtensionConfiguration
{
AllRoles = new List<ExtensionConfiguration.Extension>(),
NamedRoles = extensionConfig
}
};
var result = client.Deployments.ChangeConfigurationBySlot(resource.ServiceName, DeploymentSlot.Production, config);
这是云服务配置中的相关部分
<ServiceConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" serviceName="IS.Admin.Azure" osFamily="4" osVersion="*" schemaVersion="2014-06.2.4" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
<Role name="IS.Admin">
…
</Role>
<NetworkConfiguration>
<VirtualNetworkSite name="is-prod" />
<AddressAssignments>
<InstanceAddress roleName="IS.Admin">
<Subnets>
<Subnet name="Subnet-1" />
</Subnets>
</InstanceAddress>
<ReservedIPs>
<ReservedIP name="is-admin-rip" />
</ReservedIPs>
</AddressAssignments>
</NetworkConfiguration>
</ServiceConfiguration>
我的更新与更改/删除/添加保留 IP 无关。关于如何更新服务配置的任何想法?