azure-sdk-for-net
azure-sdk-for-net copied to clipboard
What is the SDK equivalent of Set-AzWebApp?
Library name and version
Azure.ResourceManager.AppService 1.0.0-beta-3
Query/Question
Hi there,
I'am trying to attach a custom domain name to a App Service.
In Powershell, this is how I would do it:
Set-AzWebApp -Name customdnsdev -ResourceGroupName TESTRESOURCE -HostNames @('site1.contoso.com','customdnsdev.azurewebsites.net')
How do I do this using Azure.ResourceManager.AppService?
Environment
No response
Thank you for your feedback. Tagging and routing to the team member best able to assist.
hi @josephsctan, you can achieve the custom binding by the following code
public void UpdateWebSiteCustomDomain(string resourceGroupName)
{
//this.client is an ArmClient
var resourceGroup = this.client.GetDefaultSubscription().GetResourceGroup(resourceGroupName).Value;
var website = resourceGroup.GetWebSite("your website name").Value;
HostNameBindingData data = new HostNameBindingData()
{
};
var binding=website.GetSiteHostNameBindings().CreateOrUpdate(Azure.WaitUntil.Completed, "your domain", data).Value;
}
Is this domain you purchased from external or from azure app service domain? I'm asking this because to bind a domain purchase from outside requires azure to detect if you are the owner of the domain by update some DNS record in domain provider portal, this is not something azure sdk can do
Thanks. The domain is external.
On Thu, Aug 18, 2022 at 7:06 PM Elendil @.***> wrote:
hi @josephsctan https://github.com/josephsctan, you can achieve the custom binding by the following code
public void UpdateWebSiteCustomDomain(string resourceGroupName) { var resourceGroup = this.client.GetDefaultSubscription().GetResourceGroup(resourceGroupName).Value; var website = resourceGroup.GetWebSite("your website name").Value; HostNameBindingData data = new HostNameBindingData() {
}; var binding=website.GetSiteHostNameBindings().CreateOrUpdate(Azure.WaitUntil.Completed, "your domain", data).Value; }
Is this domain you purchased from external or from azure app service domain?
— Reply to this email directly, view it on GitHub https://github.com/Azure/azure-sdk-for-net/issues/30386#issuecomment-1219113963, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOO6Z2KY5WVSO64FRYZ7S3VZXOGBANCNFSM554M2KGA . You are receiving this because you were mentioned.Message ID: @.***>
@josephsctan is there any other issue you have with the sample code? If no, feel free to let us know your overall feelings about our SDK in this Survey, thanks!
All good thanks.
The SDK pattern [ GetXXXX().CreateOrUpdate() ] certainly takes some getting used to!