public virtual ResourceLinkCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, ResourceIdentifier linkId, ResourceLinkData parameters, CancellationToken cancellationToken = default) { if (linkId == null) { throw new ArgumentNullException(nameof(linkId)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _resourceLinkClientDiagnostics.CreateScope("ResourceLinkCollection.CreateOrUpdate"); scope.Start(); try { var response = _resourceLinkRestClient.CreateOrUpdate(linkId, parameters, cancellationToken); var operation = new ResourceLinkCreateOrUpdateOperation(ArmClient, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
protected async Task <ResourceLink> CreateResourceLink(Tenant tenant, GenericResource vn1, GenericResource vn2, string resourceLinkName) { ResourceIdentifier resourceLinkId = new ResourceIdentifier(vn1.Id + "/providers/Microsoft.Resources/links/" + resourceLinkName); ResourceLinkProperties properties = new ResourceLinkProperties(vn2.Id); ResourceLinkData data = new ResourceLinkData() { Properties = properties }; ResourceLinkCreateOrUpdateOperation lro = await tenant.GetResourceLinks().CreateOrUpdateAsync(true, resourceLinkId, data); return(lro.Value); }