HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback


## EpiCloud Powershell module

To simplify usage of the Deployment API, a [PowerShell module EpiCloud](🔗), is available which contains the following cmdlets:

  • **Connect-EpiCloud** – Supplies the required credentials to other commands in the module, simplifying overall cmdlet usage.

  • **Get-EpiDeploymentPackageLocation** – Returns a SAS link to upload deployment packages to using **Add-EpiDeploymentPackage**.

  • **Add-EpiDeploymentPackage** – Upload a deployment package to the DXP environment to use for deployments; requires the Azure PowerShell modules (_Azure.Storage_ or _Az.Storage_) to run.

  • **Start-EpiDeployment** – Starts a new deployment.

  • **Get-EpiDeployment** – Fetches information about deployments (ongoing or finished).

  • **Complete-EpiDeployment** – Completes a deployment that is in the verification stage. (Same as **Complete/Go Live** in the management portal)

  • **Reset-EpiDeployment** – Resets or Complete Reset a deployment that is in the verification stage or reset-verification stage. (Same as **Reset/Complete Reset** in the management portal.)

    Note

    You can restore the database if you used **UseMaintenancePage** parameter for the deployment.

  • **Start-EpiDatabaseExport** – Starts a database export. You can specify the **wait** parameter to wait until the export has finished.

  • **Get-EpiDatabaseExport** – Get status of database export, and returns a link to the exported database if it has finished.

For examples about how to use the commands and descriptions on parameters, enter the **Get-Help** cmdlet in the PowerShell console.



Or if you want a graphical interface to access the help:



## Install the module

Get the module from the [PowerShell Gallery](🔗). To install it, open PowerShell and run the following command:



This installs the module for the current user (and does not require Administrator privileges). For instructions about using the PowerShell Gallery and the related PowerShell cmdlets for managing modules and scripts, see [Getting Started with the PowerShell Gallery](🔗) by Microsoft.

### Import the module

If you install the module from the PowerShell Gallery, the module is automatically loaded when you call a cmdlet. To explicitly import the module, use the following command:



### Add credentials to the PowerShell scope

Optionally, you can add your credentials to the current PowerShell scope by calling the **Connect-EpiCloud** cmdlet with your **ClientKey****ClientSecret**, and **ProjectId**, after which you do not have to specify the **ClientKey,** **ClientSecret**, or **ProjectId** for any other of the cmdlets in the module during the session. You also can specify these for each cmdlet if running on a build server for example.



### Upload a code package to DXP

To upload a code package to your DXP project, run **Get-EpiDeploymentPackageLocation** to get the SAS link where the package should be uploaded, and then **Add-EpiDeploymentPackage** to upload that package, as follows. See [Code package format](🔗) for details on what the package should look like.



The code package is now available for deployment.

## Deploy code and content

To start the code deployment, you can use code packages, source environment, or smooth deploy approaches.

### Deploy from the code package

To deploy this package to the Preproduction environment, use the following command:



### Deploy directly to Web App without a slot swap

To speed up deployments, use **DirectDeploy** to deploy directly to the target Web App without performing a swap. You can apply **DirectDeploy** for Integration, Development, and Testing target environments:



### Deploy from a source environment

To deploy code from a source environment, use the following command:


  • **-SourceApp **accepts app type names CMS and Commerce to specify which app from a source environment to copy.

To deploy content, use the following command:


  • **-IncludeBlob** copies BLOBs from source to target environment.

  • **-IncludeDb** copies the DB from source to target environment.

### Deploy with smooth deployment

You can use _Smooth deploy/Zero Downtime deployment (ZDD)_  for code packages and a source environment. See [Smooth deployment (Zero Downtime Deployments)](🔗) and use the following command:


  • **-ZeroDowntimeMode **accepts values ReadOnly and ReadWrite. For sites that do not support ZDD (such as Commerce Manager), a maintenance page is used instead (if those sites are part of the deployment).

### Start the deployment

The deployment starts immediately and the cmdlet returns an object that contains the Id of the deployment. If you specify the **-Wait** switch the cmdlet waits for the deployment to finish before it returns. You can use the **-UseMaintenancePage** switch to enable a maintenance page during the deployment if there are DB changes.

Use** -Verbose** for additional logging information. (This switch can be added to any cmdlet.)

If you want to check the status of deployment or just list deployments made through the API for the project, use the following command:



To get the details of a specific deployment, specify the Id of that deployment; (it returns the same type of object as **Start-EpiDeployment**):



To see details, expand the parameters property. You can also get the output as JSON:



After the deployment finishes, run **Reset** or **Complete** using the respective functions such as in the following examples:

**Complete**



**Reset**



If **UseMaintenancePage **parameter was used for the deployment, you can use **RollbackDatabase** and **ValidateBeforeSwap** options when you reset a deployment. Use **ValidateBeforeSwap **option to validate the reset progress before completing reset_._

**Complete Reset**



**Reset-EpiDeployment** and **Complete-EpiDeployment** also have a **-Wait** switch if you want the cmdlets to return after the action has finished.

Most of the cmdlets in the module also support pipelining, such as the following example:



**Start-EpiDatabaseExport**



See also: [Optimizely Cloud REST API](🔗)