6

I would like to know how to publish my Web API to an Azure Deployment Slot in VS 4 Mac.

It's straightforward to select the deployment slot I want to deploy in VS 4 Windows; I don't see that option in VS 4 Mac.

VS 4 Windows Publish Options

How can I achieve this in Mac OS?

enter image description here

Juan Martí
  • 309
  • 3
  • 5

2 Answers2

2

It can't be done from the VS Mac GUI, but you can create a publishing profile in Properties --> Publish Profile folder of your project, and enter the details manually by referring the publish profile from Azure portal.

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/visual-studio-publish-profiles?view=aspnetcore-5.0

ang
  • 679
  • 7
  • 10
0

If you want to deploy an AzureWebSite to a slot, first save the following template as an .xml file in /YOUR/SOLUTION/PROJECT/Properties/PublishProfiles/YOURPROJECT-ENV_SLOTNAME.pubxml. The values in {}'s will need to be populated.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>ZipDeploy</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <ResourceId>/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/{RESOURCE_GROUP}/providers/Microsoft.Web/sites/{YOURPROJECT}</ResourceId>
    <ResourceGroup>{RESOURCE_GROUP}</ResourceGroup>
    <PublishProvider>AzureWebSite</PublishProvider>
    <PublishUrl>{PUBLISH_URL}</PublishUrl>
    <SiteUrlToLaunchAfterPublish>{DESTINATION_URL}</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <UserName>{USERNAME}</UserName>
    <Password>{PASSWORD}</Password>
  </PropertyGroup>
</Project>

{RESOURCE_GROUP} and {SUBSCRIPTION_ID} are both found in the Azure Portal. Note: the resource group value is not the one listed on the overview screen for a resource. That one will likely be all lowercase. Currently, you can get the resource group name by:

  1. https://portal.azure.com/#view/HubsExtension/BrowseResourceGroups
  2. Find the clicking on each resource group will show the resources that belong to it.
  3. Use the value in the Name column to populate {RESOURCE_GROUP} (may have some upper case characters).

While on the resource group screen, there should be a Subscription ID value given at the top for the resource. Populate {SUBSCRIPTION_ID} with this GUID/UUID value.

Next download the publish profile for your slot. The current instructions are:

  1. Go to your App Service in https://portal.azure.com.
  2. Choose "Deployment Slots" from the tabs.
  3. Select your slot
  4. The can be downloaded using the buttons at the top of the overview, select "Download publish profile".

The remaining values will come from the downloaded publish profile. Open the downloaded publish profile file in a text editor and you will find:

<publishData>
    <publishProfile ...>
        <databases />
    </publishProfile>
    <publishProfile ...>
        <databases />
    </publishProfile>
    <publishProfile
            profileName="{YOURPROJECT} - Zip Deploy"
            publishMethod="ZipDeploy"
            publishUrl="{PUBLISH_URL}"
            userName="{USERNAME}"
            userPWD="{PASSWORD}"
            destinationAppUrl="{DESTINATION_URL}"
            SQLServerDBConnectionString="" mySQLDBConnectionString="" hostingProviderForumLink=""
            controlPanelLink="http://windows.azure.com" webSystem="WebSites">
        <databases />
    </publishProfile>
    <publishProfile ...>
        <databases />
    </publishProfile>
</publishData>

Match up the values from the {}'s with the values in the template.

Now when you right click on the project your slot should be listed as a publishing option.

Joshcodes
  • 8,513
  • 5
  • 40
  • 47