Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new command Export-PnPPowerApp #2990

Merged
merged 11 commits into from
Jul 17, 2023
Merged

Conversation

siddharth-vaghasia
Copy link
Contributor

Type

  • [x ] New Feature

Related Issues?

NA

What is in this Pull Request ?

Added new command Export-PnPPowerApp which will export a specified PowerApp as zip package, this command would be useful to automate the backup of the PowerApp/s or to automate the deployment in DevOps

Note - @gautamdsheth @KoenZomers - I would need your advise/feedback specifically on one thing... so adding some comments in PR for your comment.

resources = wrapper.Resources
};

var responseHeader = RestHelper.PostAsyncGetResponseHeader<string>(Connection.HttpClient, $"https://api.bap.microsoft.com/providers/Microsoft.BusinessAppPlatform/environments/{environmentName}/exportPackage?api-version=2016-11-01", AccessToken, payload: exportPostData).GetAwaiter().GetResult();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gautamdsheth @KoenZomers
To Export a PowerApp Package we need to make multiple API Calls, and this is 2nd call /exportpackage which returns us the location of another URL which will tell us when the download is ready but we have to keep of sending request.... and then when the status is successed it would return the url of zip file. Now the location property from this API call comes in response Headers and not as a response content so I had to introduce new functions in RestHelper which will return us headers to read the response headers properties.

So if you check in RestHelper, I have added two new functions...open to suggestions on the best way to handle this?

@@ -633,6 +649,28 @@ private static async Task<string> SendMessageAsync(HttpClient httpClient, HttpRe
}
}

private static async Task<HttpResponseHeaders> SendMessageAsyncGetResponseHeader(HttpClient httpClient, HttpRequestMessage message)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New method to make API Call but return Response Headers rather than content

@@ -289,6 +289,22 @@ public static async Task<T> PostAsync<T>(HttpClient httpClient, string url, stri
return default(T);
}

public static async Task<HttpResponseHeaders> PostAsyncGetResponseHeader<T>(HttpClient httpClient, string url, string accessToken, object payload, bool camlCasePolicy = true, string accept = "application/json")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base method which is being called from actuall command.cs file.

@gautamdsheth
Copy link
Collaborator

Can you please move the logic to a separate file or create one like PowerAppsUtility ? We can move the all these REST calls in there and keep the cmdlet clean and just return the link if available ?

Also, can you please rename the method as GetPackageLink ?

About the method names, am still thinking on how to reduce duplicate code, will get back to you on that

@siddharth-vaghasia
Copy link
Contributor Author

Can you please move the logic to a separate file or create one like PowerAppsUtility ? We can move the all these REST calls in there and keep the cmdlet clean and just return the link if available ?

Also, can you please rename the method as GetPackageLink ?

About the method names, am still thinking on how to reduce duplicate code, will get back to you on that

Hi @gautamdsheth - sorry was not able get to this sooner... I have updated as per review comments. please check now?

@gautamdsheth gautamdsheth merged commit 46ccefe into pnp:dev Jul 17, 2023
3 checks passed
@gautamdsheth
Copy link
Collaborator

Thanks @siddharth-vaghasia , merged this, amazing stuff ! Much appreciated 😊🙏
Sorry for late response.

@siddharth-vaghasia
Copy link
Contributor Author

hi @gautamdsheth - do let me know when it would be available for testing? I will test it once :)

@KoenZomers
Copy link
Collaborator

@siddharth-vaghasia Should be in the current nightly build. Every night at 2.30 AM CET a nightly build gets created which contains the latest code thus far.

@LucasCXavier
Copy link

Hi @KoenZomers, @siddharth-vaghasia. Hope you are doing well!
I'm having trouble executing this cmdlet as it's not appearing in my list of available commands. Are there any prerequisites I might be missing?
Thank you in advance!

@siddharth-vaghasia
Copy link
Contributor Author

hi @LucX4 - can you please the PnP PowerShell version you are using?

@LucasCXavier
Copy link

Hi @siddharth-vaghasia,

It's 1.12.0:

image

@LucasCXavier
Copy link

@siddharth-vaghasia,
I wasn't using the latest version. I'm able to run the command now.
Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants