Skip to content

Commit 83a91b2

Browse files
takekazuomicormacpayne
authored andcommitted
Change Get-​Azure​Rm​Web​App​Publishing​Profile -OutputFile mandatory to option. (#4827)
* Change Get-​Azure​Rm​Web​App​Publishing​Profile -OutputFile mandatory to option. OutputFile contains credentials. The current cmdlet returns XML, so you do not need to write it in a file. Mandatory is bad design. fix #4212 * update SessionRecords data for TestWebAppPublishingProfile and TestWebAppSlotPublishingProfile. * regenerate the help files. * Update Get-AzureRmWebAppPublishingProfile.md * Update Get-AzureRmWebAppSlotPublishingProfile.md * Update WebsitesClient.cs * Update WebsitesClient.cs * Update WebsitesClient.cs
1 parent d0caa08 commit 83a91b2

File tree

9 files changed

+208
-15
lines changed

9 files changed

+208
-15
lines changed

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebAppSlotTests.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,13 @@ function Test-WebAppSlotPublishingProfile
697697

698698
# Assert
699699
Assert-True { $fileZillaProfile.Name -eq $appWithSlotName3 }
700+
701+
# Get web app publishing profile without OutputFile
702+
[xml]$profile = Get-AzureRmWebAppSlotPublishingProfile -ResourceGroupName $rgname -Name $appname -Slot $slotname
703+
704+
# Assert
705+
Assert-NotNull $profile
706+
700707
}
701708
finally
702709
{

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebAppTests.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,13 @@ function Test-WebAppPublishingProfile
732732

733733
# Assert
734734
Assert-True { $fileZillaProfile.Name -eq $appName }
735+
736+
# Get web app publishing profile without OutputFile
737+
[xml]$profile = Get-AzureRmWebAppPublishingProfile -ResourceGroupName $rgname -Name $appName
738+
739+
# Assert
740+
Assert-NotNull $profile
741+
735742
}
736743
finally
737744
{

src/ResourceManager/Websites/Commands.Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppSlotTests/TestWebAppSlotPublishingProfile.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,78 @@
14071407
},
14081408
"StatusCode": 200
14091409
},
1410+
{
1411+
"RequestUri": "/subscriptions/4adb32ad-8327-4cbb-b775-b84b4465bb38/resourceGroups/onesdk6956/providers/Microsoft.Web/sites/onesdk6609/slots/staging/publishxml?api-version=2015-08-01",
1412+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNGFkYjMyYWQtODMyNy00Y2JiLWI3NzUtYjg0YjQ0NjViYjM4L3Jlc291cmNlR3JvdXBzL29uZXNkazY5NTYvcHJvdmlkZXJzL01pY3Jvc29mdC5XZWIvc2l0ZXMvb25lc2RrNjYwOS9zbG90cy9zdGFnaW5nL3B1Ymxpc2h4bWw/YXBpLXZlcnNpb249MjAxNS0wOC0wMQ==",
1413+
"RequestMethod": "POST",
1414+
"RequestBody": "{\r\n \"format\": \"WebDeploy\"\r\n}",
1415+
"RequestHeaders": {
1416+
"Content-Type": [
1417+
"application/json; charset=utf-8"
1418+
],
1419+
"Content-Length": [
1420+
"29"
1421+
],
1422+
"x-ms-client-request-id": [
1423+
"6bbd4fc4-567f-49e2-b58d-7541a99a4576"
1424+
],
1425+
"accept-language": [
1426+
"en-US"
1427+
],
1428+
"User-Agent": [
1429+
"Microsoft.Azure.Management.WebSites.WebSiteManagementClient/0.9.0.0"
1430+
],
1431+
"Accept": [
1432+
"application/json"
1433+
]
1434+
},
1435+
"ResponseBody": "<publishData>\r\n <publishProfile profileName=\"onesdk6609-staging - Web Deploy\" publishMethod=\"MSDeploy\" publishUrl=\"onesdk6609-staging.scm.azurewebsites.net:443\" msdeploySite=\"onesdk6609__staging\" userName=\"$onesdk6609__staging\" userPWD=\"pQMzRbaWQJhshregGenljb9Gy16gYSFRBw0HG7jtKQMwA7M7zyW7e44nMfSD\" destinationAppUrl=\"http://onesdk6609-staging.azurewebsites.net\" SQLServerDBConnectionString=\"\" mySQLDBConnectionString=\"\" hostingProviderForumLink=\"\" controlPanelLink=\"\" webSystem=\"WebSites\">\r\n <databases />\r\n </publishProfile>\r\n <publishProfile profileName=\"onesdk6609-staging - FTP\" publishMethod=\"FTP\" publishUrl=\"ftp://waws-prod-cq1-001.ftp.azurewebsites.windows.net/site/wwwroot\" ftpPassiveMode=\"True\" userName=\"onesdk6609__staging\\$onesdk6609__staging\" userPWD=\"pQMzRbaWQJhshregGenljb9Gy16gYSFRBw0HG7jtKQMwA7M7zyW7e44nMfSD\" destinationAppUrl=\"http://onesdk6609-staging.azurewebsites.net\" SQLServerDBConnectionString=\"\" mySQLDBConnectionString=\"\" hostingProviderForumLink=\"\" controlPanelLink=\"\" webSystem=\"WebSites\">\r\n <databases />\r\n </publishProfile>\r\n</publishData>",
1436+
"ResponseHeaders": {
1437+
"Content-Length": [
1438+
"1052"
1439+
],
1440+
"Content-Type": [
1441+
"application/xml"
1442+
],
1443+
"Expires": [
1444+
"-1"
1445+
],
1446+
"Pragma": [
1447+
"no-cache"
1448+
],
1449+
"Strict-Transport-Security": [
1450+
"max-age=31536000; includeSubDomains"
1451+
],
1452+
"x-ms-ratelimit-remaining-subscription-writes": [
1453+
"1172"
1454+
],
1455+
"x-ms-request-id": [
1456+
"afdfe6d6-479b-4d3b-b789-b15beba9456a"
1457+
],
1458+
"x-ms-correlation-request-id": [
1459+
"afdfe6d6-479b-4d3b-b789-b15beba9456a"
1460+
],
1461+
"x-ms-routing-request-id": [
1462+
"WESTUS:20151026T231512Z:afdfe6d6-479b-4d3b-b789-b15beba9456a"
1463+
],
1464+
"Cache-Control": [
1465+
"no-cache"
1466+
],
1467+
"Date": [
1468+
"Mon, 26 Oct 2015 23:15:12 GMT"
1469+
],
1470+
"Server": [
1471+
"Microsoft-IIS/8.0"
1472+
],
1473+
"X-AspNet-Version": [
1474+
"4.0.30319"
1475+
],
1476+
"X-Powered-By": [
1477+
"ASP.NET"
1478+
]
1479+
},
1480+
"StatusCode": 200
1481+
},
14101482
{
14111483
"RequestUri": "/subscriptions/4adb32ad-8327-4cbb-b775-b84b4465bb38/resourceGroups/onesdk6956/providers/Microsoft.Web/sites/onesdk6609/slots/staging/newpassword?api-version=2015-08-01",
14121484
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNGFkYjMyYWQtODMyNy00Y2JiLWI3NzUtYjg0YjQ0NjViYjM4L3Jlc291cmNlR3JvdXBzL29uZXNkazY5NTYvcHJvdmlkZXJzL01pY3Jvc29mdC5XZWIvc2l0ZXMvb25lc2RrNjYwOS9zbG90cy9zdGFnaW5nL25ld3Bhc3N3b3JkP2FwaS12ZXJzaW9uPTIwMTUtMDgtMDE=",

src/ResourceManager/Websites/Commands.Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests/TestWebAppPublishingProfile.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,79 @@
867867
},
868868
"StatusCode": 200
869869
},
870+
{
871+
"RequestUri": "/subscriptions/4adb32ad-8327-4cbb-b775-b84b4465bb38/resourceGroups/onesdk8077/providers/Microsoft.Web/sites/onesdk6930/publishxml?api-version=2015-08-01",
872+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNGFkYjMyYWQtODMyNy00Y2JiLWI3NzUtYjg0YjQ0NjViYjM4L3Jlc291cmNlR3JvdXBzL29uZXNkazgwNzcvcHJvdmlkZXJzL01pY3Jvc29mdC5XZWIvc2l0ZXMvb25lc2RrNjkzMC9wdWJsaXNoeG1sP2FwaS12ZXJzaW9uPTIwMTUtMDgtMDE=",
873+
"RequestMethod": "POST",
874+
"RequestBody": "{\r\n \"format\": \"WebDeploy\"\r\n}",
875+
"RequestHeaders": {
876+
"Content-Type": [
877+
"application/json; charset=utf-8"
878+
],
879+
"Content-Length": [
880+
"29"
881+
],
882+
"x-ms-client-request-id": [
883+
"e353aec7-bb13-4bc8-8465-928483f547cb"
884+
],
885+
"accept-language": [
886+
"en-US"
887+
],
888+
"User-Agent": [
889+
"Microsoft.Azure.Management.WebSites.WebSiteManagementClient/0.9.0.0"
890+
],
891+
"Accept": [
892+
"application/json"
893+
]
894+
},
895+
"ResponseBody": "<publishData>\r\n <publishProfile profileName=\"onesdk6930 - Web Deploy\" publishMethod=\"MSDeploy\" publishUrl=\"onesdk6930.scm.azurewebsites.net:443\" msdeploySite=\"onesdk6930\" userName=\"$onesdk6930\" userPWD=\"tYrdZt5XqK5y8imerjX26WZmkRdDftbvThl34vX1JA4HgjjtbXw5YhJxcq3F\" destinationAppUrl=\"http://onesdk6930.azurewebsites.net\" SQLServerDBConnectionString=\"\" mySQLDBConnectionString=\"\" hostingProviderForumLink=\"\" controlPanelLink=\"\" webSystem=\"WebSites\">\r\n <databases />\r\n </publishProfile>\r\n <publishProfile profileName=\"onesdk6930 - FTP\" publishMethod=\"FTP\" publishUrl=\"ftp://waws-prod-cq1-001.ftp.azurewebsites.windows.net/site/wwwroot\" ftpPassiveMode=\"True\" userName=\"onesdk6930\\$onesdk6930\" userPWD=\"tYrdZt5XqK5y8imerjX26WZmkRdDftbvThl34vX1JA4HgjjtbXw5YhJxcq3F\" destinationAppUrl=\"http://onesdk6930.azurewebsites.net\" SQLServerDBConnectionString=\"\" mySQLDBConnectionString=\"\" hostingProviderForumLink=\"\" controlPanelLink=\"\" webSystem=\"WebSites\">\r\n <databases />\r\n </publishProfile>\r\n</publishData>",
896+
"ResponseHeaders": {
897+
"Content-Length": [
898+
"976"
899+
],
900+
"Content-Type": [
901+
"application/xml"
902+
],
903+
"Expires": [
904+
"-1"
905+
],
906+
"Pragma": [
907+
"no-cache"
908+
],
909+
"Strict-Transport-Security": [
910+
"max-age=31536000; includeSubDomains"
911+
],
912+
"x-ms-ratelimit-remaining-subscription-resource-requests": [
913+
"11998"
914+
],
915+
"x-ms-request-id": [
916+
"d9128a68-dcf4-4319-9564-9e3b509efaed"
917+
],
918+
"x-ms-correlation-request-id": [
919+
"d9128a68-dcf4-4319-9564-9e3b509efaed"
920+
],
921+
"x-ms-routing-request-id": [
922+
"WESTUS:20151026T225346Z:d9128a68-dcf4-4319-9564-9e3b509efaed"
923+
],
924+
"Cache-Control": [
925+
"no-cache"
926+
],
927+
"Date": [
928+
"Mon, 26 Oct 2015 22:53:46 GMT"
929+
],
930+
"Server": [
931+
"Microsoft-IIS/8.0"
932+
],
933+
"X-AspNet-Version": [
934+
"4.0.30319"
935+
],
936+
"X-Powered-By": [
937+
"ASP.NET"
938+
]
939+
},
940+
"StatusCode": 200
941+
},
942+
870943
{
871944
"RequestUri": "/subscriptions/4adb32ad-8327-4cbb-b775-b84b4465bb38/resourceGroups/onesdk8077/providers/Microsoft.Web/sites/onesdk6930/newpassword?api-version=2015-08-01",
872945
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNGFkYjMyYWQtODMyNy00Y2JiLWI3NzUtYjg0YjQ0NjViYjM4L3Jlc291cmNlR3JvdXBzL29uZXNkazgwNzcvcHJvdmlkZXJzL01pY3Jvc29mdC5XZWIvc2l0ZXMvb25lc2RrNjkzMC9uZXdwYXNzd29yZD9hcGktdmVyc2lvbj0yMDE1LTA4LTAx",

src/ResourceManager/Websites/Commands.Websites/Cmdlets/DeploymentSlots/GetAzureWebAppSlotPublishingProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class GetAzureWebAppSlotPublishingProfileCmdlet : WebAppSlotBaseCmdlet
2828
{
2929
private const string DefaultFormat = "WebDeploy";
3030

31-
[Parameter(Position = 3, Mandatory = true, HelpMessage = "The file the publishing profile will we saved as")]
31+
[Parameter(Position = 3, Mandatory = false, HelpMessage = "The file the publishing profile will we saved as")]
3232
public string OutputFile { get; set; }
3333

3434
[Parameter(Position = 4, Mandatory = false, HelpMessage = "The format of the profile. Allowed values are [WebDeploy|FileZilla3|Ftp]. Default value is WebDeploy")]

src/ResourceManager/Websites/Commands.Websites/Cmdlets/WebApps/GetAzureWebAppPublishingProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class GetAzureWebAppPublishingProfileCmdlet : WebAppBaseCmdlet
2626
{
2727
private const string DefaultFormat = "WebDeploy";
2828

29-
[Parameter(Position = 2, Mandatory = true, HelpMessage = "The file the publishing profile will we saved as")]
29+
[Parameter(Position = 2, Mandatory = false, HelpMessage = "The file the publishing profile will we saved as")]
3030
public string OutputFile { get; set; }
3131

3232
[Parameter(Position = 3, Mandatory = false, HelpMessage = "The format of the profile. Allowed values are [WebDeploy|FileZilla3|Ftp]. Default value is WebDeploy")]

src/ResourceManager/Websites/Commands.Websites/Utilities/WebsitesClient.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ public string GetWebAppPublishingProfile(string resourceGroupName, string webSit
263263
WrappedWebsitesClient.WebApps().ListSitePublishingProfileXmlSlot(resourceGroupName, webSiteName, options, slotName) :
264264
WrappedWebsitesClient.WebApps().ListSitePublishingProfileXml(resourceGroupName, webSiteName, options));
265265
var doc = XDocument.Load(publishingXml, LoadOptions.None);
266-
doc.Save(outputFile, SaveOptions.OmitDuplicateNamespaces);
266+
if (outputFile != null)
267+
{
268+
doc.Save(outputFile, SaveOptions.OmitDuplicateNamespaces);
269+
}
267270
return doc.ToString();
268271
}
269272

src/ResourceManager/Websites/Commands.Websites/help/Get-AzureRmWebAppPublishingProfile.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
external help file: Microsoft.Azure.Commands.Websites.dll-Help.xml
3+
Module Name: AzureRM.Websites
34
ms.assetid: 38433470-CAFD-4B8F-980C-63D4B264B39F
45
online version:
56
schema: 2.0.0
@@ -14,14 +15,14 @@ Gets an Azure Web App publishing profile.
1415

1516
### S1
1617
```
17-
Get-AzureRmWebAppPublishingProfile [-OutputFile] <String> [[-Format] <String>] [-ResourceGroupName] <String>
18-
[-Name] <String> [<CommonParameters>]
18+
Get-AzureRmWebAppPublishingProfile [[-OutputFile] <String>] [[-Format] <String>] [-ResourceGroupName] <String>
19+
[-Name] <String> [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
1920
```
2021

2122
### S2
2223
```
23-
Get-AzureRmWebAppPublishingProfile [-OutputFile] <String> [[-Format] <String>] [-WebApp] <Site>
24-
[<CommonParameters>]
24+
Get-AzureRmWebAppPublishingProfile [[-OutputFile] <String>] [[-Format] <String>] [-WebApp] <Site>
25+
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
2526
```
2627

2728
## DESCRIPTION
@@ -39,6 +40,21 @@ This command gets the publishing profile in Ftp format for Web App ContosoWebApp
3940

4041
## PARAMETERS
4142

43+
### -DefaultProfile
44+
The credentials, account, tenant, and subscription used for communication with azure.
45+
46+
```yaml
47+
Type: IAzureContextContainer
48+
Parameter Sets: (All)
49+
Aliases: AzureRmContext, AzureCredential
50+
51+
Required: False
52+
Position: Named
53+
Default value: None
54+
Accept pipeline input: False
55+
Accept wildcard characters: False
56+
```
57+
4258
### -Format
4359
Format
4460
@@ -78,7 +94,7 @@ Type: String
7894
Parameter Sets: (All)
7995
Aliases:
8096

81-
Required: True
97+
Required: False
8298
Position: 2
8399
Default value: None
84100
Accept pipeline input: False
@@ -121,7 +137,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
121137
## INPUTS
122138
123139
### Site
124-
125140
Parameter 'WebApp' accepts value of type 'Site' from the pipeline
126141
127142
## OUTPUTS

src/ResourceManager/Websites/Commands.Websites/help/Get-AzureRmWebAppSlotPublishingProfile.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
external help file: Microsoft.Azure.Commands.Websites.dll-Help.xml
3+
Module Name: AzureRM.Websites
34
ms.assetid: B2FDB54F-0318-4037-BC1D-6113E77DDE7E
45
online version:
56
schema: 2.0.0
@@ -14,14 +15,15 @@ Gets an Azure Web App slot publishing profile.
1415

1516
### S1
1617
```
17-
Get-AzureRmWebAppSlotPublishingProfile [-OutputFile] <String> [[-Format] <String>]
18-
[-ResourceGroupName] <String> [-Name] <String> [-Slot] <String> [<CommonParameters>]
18+
Get-AzureRmWebAppSlotPublishingProfile [[-OutputFile] <String>] [[-Format] <String>]
19+
[-ResourceGroupName] <String> [-Name] <String> [-Slot] <String> [-DefaultProfile <IAzureContextContainer>]
20+
[<CommonParameters>]
1921
```
2022

2123
### S2
2224
```
23-
Get-AzureRmWebAppSlotPublishingProfile [-OutputFile] <String> [[-Format] <String>] [-WebApp] <Site>
24-
[<CommonParameters>]
25+
Get-AzureRmWebAppSlotPublishingProfile [[-OutputFile] <String>] [[-Format] <String>] [-WebApp] <Site>
26+
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
2527
```
2628

2729
## DESCRIPTION
@@ -39,6 +41,21 @@ This command gets the publishing profile in Ftp format for slot Slot001 pertaini
3941

4042
## PARAMETERS
4143

44+
### -DefaultProfile
45+
The credentials, account, tenant, and subscription used for communication with azure.
46+
47+
```yaml
48+
Type: IAzureContextContainer
49+
Parameter Sets: (All)
50+
Aliases: AzureRmContext, AzureCredential
51+
52+
Required: False
53+
Position: Named
54+
Default value: None
55+
Accept pipeline input: False
56+
Accept wildcard characters: False
57+
```
58+
4259
### -Format
4360
Format
4461
@@ -78,7 +95,7 @@ Type: String
7895
Parameter Sets: (All)
7996
Aliases:
8097

81-
Required: True
98+
Required: False
8299
Position: 3
83100
Default value: None
84101
Accept pipeline input: False
@@ -136,7 +153,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
136153
## INPUTS
137154
138155
### Site
139-
140156
Parameter 'WebApp' accepts value of type 'Site' from the pipeline
141157
142158
## OUTPUTS

0 commit comments

Comments
 (0)