@@ -132,7 +132,7 @@ public void ExecuteCmdletActions(SessionState state)
132
132
if ( ParameterSetName == SimpleParameterSet )
133
133
{
134
134
ValidateWebAppName ( Name ) ;
135
- if ( ShouldProcess ( string . Format ( Resources . SimpleWebAppCreateTarget , Name ) , Resources . SimpleWebAppCreateAction ) )
135
+ if ( ShouldProcess ( string . Format ( Microsoft . Azure . Commands . WebApps . Properties . Resources . SimpleWebAppCreateTarget , Name ) , Microsoft . Azure . Commands . WebApps . Properties . Resources . SimpleWebAppCreateAction ) )
136
136
{
137
137
var adapter = new PSCmdletAdapter ( this , state ) ;
138
138
adapter . WaitForCompletion ( CreateWithSimpleParameters ) ;
@@ -150,11 +150,19 @@ public void ExecuteCmdletActions(SessionState state)
150
150
151
151
private void ValidateWebAppName ( string name )
152
152
{
153
+ #if ! NETSTANDARD
153
154
var available = WebsitesClient . WrappedWebsitesClient . GlobalModel . CheckNameAvailability ( new ResourceNameAvailabilityRequest { Name = name , Type = "Site" } ) ;
154
155
if ( available . NameAvailable . HasValue && ! available . NameAvailable . Value )
155
156
{
156
157
throw new InvalidOperationException ( string . Format ( "Website name '{0}' is not available. Please try a different name." , name ) ) ;
157
158
}
159
+ #else
160
+ var available = WebsitesClient . WrappedWebsitesClient . CheckNameAvailability ( name , "Site" ) ;
161
+ if ( available . NameAvailable . HasValue && ! available . NameAvailable . Value )
162
+ {
163
+ throw new InvalidOperationException ( string . Format ( "Website name '{0}' is not available. Please try a different name." , name ) ) ;
164
+ }
165
+ #endif
158
166
}
159
167
160
168
public void CreateWithClonedWebApp ( )
@@ -202,7 +210,7 @@ public void CreateWithClonedWebApp()
202
210
CloneSlots ( slotNames ) ;
203
211
}
204
212
}
205
-
213
+ #if ! NETSTANDARD
206
214
private async Task < ServerFarmWithRichSku > GetDefaultServerFarm ( string location )
207
215
{
208
216
var websiteLocation = string . IsNullOrWhiteSpace ( location ) ? new LocationConstraint ( ) : new LocationConstraint ( location ) ;
@@ -225,6 +233,31 @@ private async Task<ServerFarmWithRichSku> GetDefaultServerFarm(string location)
225
233
226
234
return defaultFarm ;
227
235
}
236
+ #else
237
+ private async Task < AppServicePlan > GetDefaultServerFarm ( string location )
238
+ {
239
+ var websiteLocation = string . IsNullOrWhiteSpace ( location ) ? new LocationConstraint ( ) : new LocationConstraint ( location ) ;
240
+ var farmResources = await ResourcesClient . ResourceManagementClient . Resources . ListAsync ( new ODataQuery < GenericResourceFilter > ( r => r . ResourceType == "Microsoft.Web/serverFarms" ) ) ;
241
+ AppServicePlan defaultFarm = null ;
242
+ foreach ( var resource in farmResources )
243
+ {
244
+ // Try to find a policy with Sku=Free and available site capacity
245
+ var id = new ResourceIdentifier ( resource . Id ) ;
246
+ var farm = await WebsitesClient . WrappedWebsitesClient . AppServicePlans . GetAsync ( id . ResourceGroupName , id . ResourceName ) ;
247
+ if ( websiteLocation . Match ( farm . Location )
248
+ && string . Equals ( "free" , farm . Sku ? . Tier ? . ToLower ( ) , StringComparison . OrdinalIgnoreCase )
249
+ && farm . NumberOfSites < MaxFreeSites )
250
+ {
251
+ defaultFarm = farm ;
252
+ break ;
253
+ }
254
+
255
+ }
256
+
257
+ return defaultFarm ;
258
+ }
259
+
260
+ #endif
228
261
229
262
bool TryGetServerFarmFromResourceId ( string serverFarm , out string resourceGroup , out string serverFarmName )
230
263
{
@@ -269,7 +302,11 @@ public async Task CreateWithSimpleParameters(ICmdletAdapter adapter)
269
302
if ( farm != null )
270
303
{
271
304
planResourceGroup = farm . ResourceGroup ;
305
+ #if ! NETSTANDARD
272
306
planName = farm . ServerFarmWithRichSkuName ;
307
+ #else
308
+ planName = farm . Name ;
309
+ #endif
273
310
planRG = ResourceGroupStrategy . CreateResourceGroupConfig ( planResourceGroup ) ;
274
311
}
275
312
}
@@ -295,7 +332,11 @@ public async Task CreateWithSimpleParameters(ICmdletAdapter adapter)
295
332
var scmHostName = output . EnabledHostNames . FirstOrDefault ( s => s . Contains ( ".scm." ) ) ;
296
333
if ( ! string . IsNullOrWhiteSpace ( scmHostName ) )
297
334
{
335
+ #if ! NETSTANDARD
298
336
var profile = await WebsitesClient . WrappedWebsitesClient . Sites . ListSitePublishingProfileXmlAsync ( output . ResourceGroup , output . SiteName , new CsmPublishingProfileOptions { Format = "WebDeploy" } ) ;
337
+ #else
338
+ var profile = await WebsitesClient . WrappedWebsitesClient . WebApps . ListPublishingProfileXmlWithSecretsAsync ( output . ResourceGroup , output . Name , new CsmPublishingProfileOptions { Format = "WebDeploy" } ) ;
339
+ #endif
299
340
var doc = new XmlDocument ( ) ;
300
341
doc . Load ( profile ) ;
301
342
userName = doc . SelectSingleNode ( "//publishProfile[@publishMethod=\" MSDeploy\" ]/@userName" ) . Value ;
@@ -318,7 +359,7 @@ public async Task CreateWithSimpleParameters(ICmdletAdapter adapter)
318
359
else if ( ! string . IsNullOrWhiteSpace ( userName ) && ! string . IsNullOrWhiteSpace ( password ) )
319
360
{
320
361
await git . AddRemoteRepository ( "azure" , $ "https://{ userName } :{ password } @{ scmHostName } ") ;
321
- adapter . WriteVerboseAsync ( Resources . GitRemoteMessage ) ;
362
+ adapter . WriteVerboseAsync ( Microsoft . Azure . Commands . WebApps . Properties . Resources . GitRemoteMessage ) ;
322
363
newOutput . GitRemoteName = "azure" ;
323
364
}
324
365
}
@@ -328,9 +369,8 @@ public async Task CreateWithSimpleParameters(ICmdletAdapter adapter)
328
369
{
329
370
// do not write errors for problems with adding git repository
330
371
var repoPath = GitRepositoryPath ?? adapter ? . SessionState ? . Path ? . CurrentFileSystemLocation ? . Path ;
331
- adapter . WriteWarningAsync ( String . Format ( Resources . GitRemoteAddFailure , repoPath , exception . Message ) ) ;
372
+ adapter . WriteWarningAsync ( String . Format ( Microsoft . Azure . Commands . WebApps . Properties . Resources . GitRemoteAddFailure , repoPath , exception . Message ) ) ;
332
373
}
333
-
334
374
adapter . WriteObjectAsync ( output ) ;
335
375
}
336
376
0 commit comments